1.14.4 Multi Language

Discussion in 'Spigot Plugin Development' started by DevSnx, Feb 7, 2020.

Thread Status:
Not open for further replies.
  1. DevSnx

    DevSnx Previously Snx

    Hello guys,

    I will add a multi language to my Plugins!

    I will create folder "languages" in the Plguin folder with files "en_EN.yml" "de_DE.yml" but i can use or get it?

    my source -> github
     
    #1 DevSnx, Feb 7, 2020
    Last edited: Feb 8, 2020
  2. have a config setting that allows a person to change what language file they want to use.
     
  3. DevSnx

    DevSnx Previously Snx

    yes u can set in config language: en | de but i can get the file en or de?
     
  4. new File(your plugin folder + the language setting + ".yml");

    then load the file with YamlConfiguration.
     
  5. DevSnx

    DevSnx Previously Snx

    i know xd but i have 2 or more languages files.. so how get a de file or en file? :D
     
  6. new File(your plugin folder + languageSetting + ".yml");

    The language setting would depend on the value in the config.

    So, languageSetting is a String variable that would be whatever the value you get from the config.
     
  7. DevSnx

    DevSnx Previously Snx

    yes i have it done.

    but does it have to create the "Languages" folder and the .yml file itself or can I drag them as standard configs into the resources folder and they will be loaded automatically?

    For infos check my Code please! Github
     
  8. Then look at the documentation for saveResource()

    Check if the file exists. If it doesn't, create the necessary directories, and call saveResource.
     
    • Useful Useful x 1
  9. DevSnx

    DevSnx Previously Snx

    Thanks!
     
    #9 DevSnx, Feb 7, 2020
    Last edited: Feb 8, 2020
  10. Code (Java):
    FieUtils.copyInputStreamToFile(this.getResource("languages/file.yml"), new File("languages/anotherfile.yml"));
     
Thread Status:
Not open for further replies.