Module bus.mapper

Class Locale

java.lang.Object
org.miaixz.bus.mapper.Locale

public class Locale extends Object
多语言支持工具类,支持通过 JVM 参数设置 Locale,例如:-Duser.country=US -Duser.language=en
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Locale

      public Locale()
  • Method Details

    • message

      public static String message(Locale locale, String bundleName, String key, Object... args)
      获取指定语言的格式化文本,当资源文件或键不存在时,返回 MessageFormat.format(key, args)
      Parameters:
      locale - 语言环境
      bundleName - 资源文件名
      key - 字符串键
      args - 格式化参数
      Returns:
      格式化后的文本
    • message

      public static String message(String bundleName, String key, Object... args)
      获取默认语言环境的格式化文本,当资源文件或键不存在时,返回 MessageFormat.format(key, args)
      Parameters:
      bundleName - 资源文件名
      key - 字符串键
      args - 格式化参数
      Returns:
      格式化后的文本
    • language

      public static Locale.Language language(Locale locale, String bundleName)
      获取指定语言环境的语言包。
      Parameters:
      locale - 语言环境
      bundleName - 语言包名称
      Returns:
      语言包实例
    • language

      public static Locale.Language language(String bundleName)
      获取默认语言环境的语言包。
      Parameters:
      bundleName - 语言包名称
      Returns:
      语言包实例