You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
10 years ago
|
package ru.simsonic.rscPermissions.Engine;
|
||
10 years ago
|
import java.io.File;
|
||
10 years ago
|
import java.io.FileOutputStream;
|
||
10 years ago
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
10 years ago
|
import java.nio.channels.Channels;
|
||
|
import java.nio.channels.FileChannel;
|
||
10 years ago
|
import ru.simsonic.rscPermissions.API.TranslationProvider;
|
||
|
import ru.simsonic.rscPermissions.BukkitPluginMain;
|
||
10 years ago
|
|
||
|
public enum Phrases
|
||
|
{
|
||
|
PLUGIN_ENABLED ("generic.enabled"),
|
||
|
PLUGIN_DISABLED ("generic.disabled"),
|
||
|
PLUGIN_METRICS ("generic.metrics"),
|
||
|
PLUGIN_RELOADED ("generic.reloaded"),
|
||
10 years ago
|
MYSQL_FETCHED ("mysql.fetched"),
|
||
10 years ago
|
;
|
||
10 years ago
|
private final String node;
|
||
|
private String phrase;
|
||
|
private Phrases(String node)
|
||
|
{
|
||
|
this.node = node;
|
||
|
}
|
||
|
@Override
|
||
|
public String toString()
|
||
|
{
|
||
|
return phrase;
|
||
|
}
|
||
10 years ago
|
public static void translate(TranslationProvider provider)
|
||
10 years ago
|
{
|
||
|
for(Phrases value : Phrases.values())
|
||
10 years ago
|
value.phrase = provider.getString(value.node);
|
||
10 years ago
|
}
|
||
10 years ago
|
public static void extractAll(File workingDir)
|
||
10 years ago
|
{
|
||
10 years ago
|
extract(workingDir, "english");
|
||
|
extract(workingDir, "russian");
|
||
10 years ago
|
}
|
||
10 years ago
|
public static void extract(File workingDir, String langName)
|
||
10 years ago
|
{
|
||
|
try
|
||
|
{
|
||
10 years ago
|
final File langFile = new File(workingDir, langName + ".yml");
|
||
10 years ago
|
if(!langFile.isFile())
|
||
|
{
|
||
10 years ago
|
final FileChannel fileChannel = new FileOutputStream(langFile).getChannel();
|
||
10 years ago
|
final InputStream langStream = BukkitPluginMain.class.getResourceAsStream("/languages/" + langName + ".yml");
|
||
10 years ago
|
fileChannel.transferFrom(Channels.newChannel(langStream), 0, Long.MAX_VALUE);
|
||
10 years ago
|
}
|
||
|
} catch(IOException ex) {
|
||
|
}
|
||
|
}
|
||
|
}
|