Class PluginI18n

java.lang.Object
cn.nukkit.lang.PluginI18n

@PowerNukkitXOnly @Since("1.19.60-r1") public class PluginI18n extends Object
  • Constructor Details

    • PluginI18n

      public PluginI18n(PluginBase plugin)
  • Method Details

    • tr

      public String tr(LangCode lang, String key)
      翻译一个文本key,key从语言文件中查询

      Translate a text key, the key is queried from the language file

      Parameters:
      lang - 要翻译的语言
      key - the key
      Returns:
      the string
    • tr

      public String tr(LangCode lang, String key, String... args)
      翻译一个文本key,key从语言文件中查询,并且按照给定参数填充其中参数

      Translate a text key, the key is queried from the language file and the parameters are filled according to the given parameters

      Parameters:
      lang - 要翻译的语言
      key - the key
      args - the args
      Returns:
      the string
    • tr

      public String tr(LangCode lang, String key, Object... args)
      翻译一个文本key,key从语言文件中查询,并且按照给定参数填充其中参数

      Translate a text key, the key is queried from the language file and the parameters are filled according to the given parameters

      Parameters:
      lang - 要翻译的语言
      key - the key
      args - the args
      Returns:
      the string
    • tr

      public String tr(LangCode lang, TextContainer c)
      翻译文本容器

      Tr string.

      Parameters:
      lang - 要翻译的语言
      c - the c
      Returns:
      the string
    • get

      public String get(LangCode lang, String id)
      获取指定id对应的多语言文本,若不存在则返回null

      Get the multilingual text corresponding to the specified id, or return null if it does not exist

      Parameters:
      id - the id
      Returns:
      the string
    • getOrOriginal

      public String getOrOriginal(LangCode lang, String id)
      获取指定id对应的多语言文本,若不存在则返回id本身

      Get the multilingual text corresponding to the specified id, or return the id itself if it does not exist

      Parameters:
      id - the id
      Returns:
      the string
    • parseLanguageText

      protected String parseLanguageText(LangCode lang, String str)
    • addLang

      public void addLang(LangCode langName, String path)
      Add lang.
      Parameters:
      langName - the lang name
      path - the path
    • addLang

      public void addLang(LangCode langName, InputStream stream)
      Add lang.
      Parameters:
      langName - the lang name
      stream - the stream
    • reloadLang

      public boolean reloadLang(LangCode lang, String path)
      Reload lang boolean.
      Parameters:
      lang - the lang
      path - the path
      Returns:
      the boolean
    • reloadLang

      public boolean reloadLang(LangCode lang, InputStream stream)
      Reload lang boolean.
      Parameters:
      lang - the lang
      stream - the stream
      Returns:
      the boolean
    • getFallbackLanguage

      public LangCode getFallbackLanguage()
      Gets fallback language.
      Returns:
      the fallback language
    • setFallbackLanguage

      public void setFallbackLanguage(LangCode fallback)
      Sets fallback language.
      Parameters:
      fallback - the fallback
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • parseArg

      protected String parseArg(Object arg)