I have multiple language files in one directory inside my project. Those language files are basically custom config-files, which I want to save as well inside a sub-folder in my plugin-folder.
I have edited my pom.xml
to implement the .yml
files into the compressed .jar
<resource>
<directory>${basedir}/src/main/resources/languages</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
This is working so far, but when I save the config-files,
File file = new File(Main.getPlugin().getDataFolder(),
ConfigManager.getConf().getString("Settings.language") + "_lang.yml");
if (!file.exists()) {
System.out.println("This language file does not exist!");
file.getParentFile().mkdirs();
}
Main.getPlugin().saveResource(file.getName(), true);
conf = YamlConfiguration.loadConfiguration(file);
they won't be saved inside a subfolder, when the plugin loads.
I have tried to tell the File()
function, that it should use a different location such as
File file = new File(Main.getPlugin().getDataFolder() + System.getProperty("file.separator") + "languages",
ConfigManager.getConf().getString("Settings.language") + "_lang.yml");
but it didn't work.
I could use the current way, that the language-files won't get saved inside a sub-folder, but with the time and more lang-files, it'll get very confusing, if there are too many files.
If this method I'm using is "a stupid way", I'm fine, if somebody else could tell me a way how to write a better "language-switcher".