1.16.5 Language system help

Discussion in 'Spigot Plugin Development' started by WailRoth, Jul 12, 2021.

  1. Hello,
    I need your help for create language system, with X languages.
    Idk how i can do that, so if anyone has an idea, i take it !
     
  2. If you already have the translations, have a look at ResourceBundle. If you're looking to allow users to add their own translations you can supplement the ResourceBundle with YML-files saved on disk, in a lang-folder, and simply load the strings into a map.
     
    • Like Like x 1
  3. Very interresting
     
  4. Yeah but, how can i retrieve "tranlation 2"

    Code (Java):
    {"not_permission_message", "&cYou don't have permission.", "Vous n'avez pas la permission"},
     
  5. Ah, you create separate files per translation. If you use ResourceBundle, your files should look like this: PluginName_LocaleTag.properties
    E.g. MyPlugin_fr_FR.properties or MyPlugin_en_GB.properties.

    If you're using YML-files on disk, consider naming them in the same way, but with the .yml-extension.
    E.g. MyPlugin_fr_FR.yml and MyPlugin_en_GB.yml

    Once you've done that, you just load the default, or specified ResourceBundle/file at Runtime. If you wanna be fancy, you can allow the user to switch languages during runtime, but probably best to let them specify the language in the config.yml
     
  6. Yeah, but how can i select the language, like for Player1, he is english, i need to get english translation for his message, same for Player2 that is French
     
  7. You could create a LanguageManager, and load all the necessary languages in there. Then you need to find some way to save which player needs what language. You could probably create a PluginPlayer class and save the selected Locale in the PluginPlayer class.
     
  8. Yeah i know that, and i know how to do it, RessourceBundle is just the problem