Skip to content

Commit

Permalink
default load zh_CN, remove long Skipped log
Browse files Browse the repository at this point in the history
  • Loading branch information
Librazy committed Dec 28, 2018
1 parent 8563651 commit 55f5834
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/meowj/langutils/LangUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
Expand All @@ -40,8 +39,9 @@ public void onEnable() {
}

config.addDefault("FallbackLanguage", "en_us");
List<String> defaultLang = new ArrayList<String>();
List<String> defaultLang = new ArrayList<>();
defaultLang.add("en_us");
defaultLang.add("zh_cn");
config.addDefault("LoadLanguage", defaultLang);
config.options().copyDefaults(true);
saveConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ public class LanguageRegistry {
public String registerEntry(EnumLang lang, String unlocalizedName, String localizedName) {
return lang.getMap().put(unlocalizedName, localizedName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static EnumLang get(String locale) {
public static void init() {
for (EnumLang enumLang : EnumLang.values()) {
if (!LangUtils.plugin.config.getStringList("LoadLanguage").contains("all") && !LangUtils.plugin.config.getStringList("LoadLanguage").contains(enumLang.getLocale())) {
LangUtils.plugin.info("Skipped " + enumLang.getLocale());
LangUtils.plugin.getLogger().fine("Skipped " + enumLang.getLocale());
continue;
}
try {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/meowj/langutils/locale/LocaleHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,22 @@ public static void toPlainText(StringBuilder builder, BaseComponent baseComponen

public static String toLegacyText(BaseComponent component, String locale) {
StringBuilder builder = new StringBuilder();
toLegacyText(builder, component, locale);
if (component instanceof TranslatableComponent) {
toLegacyText(builder, (TranslatableComponent) component, locale);
} else {
toLegacyText(builder, component, locale);
}
return builder.toString();
}


public static String toPlainText(BaseComponent component, String locale) {
StringBuilder builder = new StringBuilder();
toPlainText(builder, component, locale);
if (component instanceof TranslatableComponent) {
toPlainText(builder, (TranslatableComponent) component, locale);
} else {
toPlainText(builder, component, locale);
}
return builder.toString();
}
}

0 comments on commit 55f5834

Please sign in to comment.