feat: wip translations
This commit is contained in:
parent
5d3a99f72d
commit
c929e73b0d
17 changed files with 148 additions and 94 deletions
|
@ -14,6 +14,8 @@ public class AdminGUI {
|
||||||
|
|
||||||
public AdminGUI(Player player) {
|
public AdminGUI(Player player) {
|
||||||
final HomeGUI parent = new HomeGUI(player);
|
final HomeGUI parent = new HomeGUI(player);
|
||||||
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
||||||
this.gui = Gui.normal()
|
this.gui = Gui.normal()
|
||||||
.setStructure(
|
.setStructure(
|
||||||
"# # # # # # # # #",
|
"# # # # # # # # #",
|
||||||
|
@ -22,7 +24,7 @@ public class AdminGUI {
|
||||||
)
|
)
|
||||||
.addIngredient('S', new ManageCacheItem())
|
.addIngredient('S', new ManageCacheItem())
|
||||||
.addIngredient('C', new ManagePlayerItem())
|
.addIngredient('C', new ManagePlayerItem())
|
||||||
.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()))
|
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
||||||
.build();
|
.build();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ public class CacheDetailedGUI {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
final CacheManagementGUI parent = new CacheManagementGUI(player);
|
final CacheManagementGUI parent = new CacheManagementGUI(player);
|
||||||
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
||||||
gui = ScrollGui.items(guiItemBuilder -> {
|
gui = ScrollGui.items(guiItemBuilder -> {
|
||||||
guiItemBuilder.setStructure(
|
guiItemBuilder.setStructure(
|
||||||
"x x x x x x x x U",
|
"x x x x x x x x U",
|
||||||
|
@ -48,7 +50,7 @@ public class CacheDetailedGUI {
|
||||||
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
|
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
|
||||||
guiItemBuilder.addIngredient('U', new ScrollUpItem());
|
guiItemBuilder.addIngredient('U', new ScrollUpItem());
|
||||||
guiItemBuilder.addIngredient('D', new ScrollDownItem());
|
guiItemBuilder.addIngredient('D', new ScrollDownItem());
|
||||||
guiItemBuilder.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()));
|
guiItemBuilder.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()));
|
||||||
guiItemBuilder.setContent(items);
|
guiItemBuilder.setContent(items);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,15 @@ public class CacheManagementGUI {
|
||||||
|
|
||||||
public CacheManagementGUI(Player player) {
|
public CacheManagementGUI(Player player) {
|
||||||
final AdminGUI parent = new AdminGUI(player);
|
final AdminGUI parent = new AdminGUI(player);
|
||||||
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
||||||
this.gui = Gui.normal()
|
this.gui = Gui.normal()
|
||||||
.setStructure(
|
.setStructure(
|
||||||
"# # # # # # # # #",
|
"# # # # # # # # #",
|
||||||
"# # # S A D # # #",
|
"# # # S A D # # #",
|
||||||
"B # # # # # # # #"
|
"B # # # # # # # #"
|
||||||
)
|
)
|
||||||
.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()))
|
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
||||||
.addIngredient('S', new CacheStatisticsItem())
|
.addIngredient('S', new CacheStatisticsItem())
|
||||||
.addIngredient('A', new InvalidateCacheItem())
|
.addIngredient('A', new InvalidateCacheItem())
|
||||||
.addIngredient('D', new InvalidateEntryItem())
|
.addIngredient('D', new InvalidateEntryItem())
|
||||||
|
|
|
@ -29,6 +29,8 @@ public class PlayerCheckGUI {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
final AdminGUI parent = new AdminGUI(player);
|
final AdminGUI parent = new AdminGUI(player);
|
||||||
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
||||||
gui = ScrollGui.items(guiItemBuilder -> {
|
gui = ScrollGui.items(guiItemBuilder -> {
|
||||||
guiItemBuilder.setStructure(
|
guiItemBuilder.setStructure(
|
||||||
"x x x x x x x x U",
|
"x x x x x x x x U",
|
||||||
|
@ -40,7 +42,7 @@ public class PlayerCheckGUI {
|
||||||
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
|
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
|
||||||
guiItemBuilder.addIngredient('U', new ScrollUpItem());
|
guiItemBuilder.addIngredient('U', new ScrollUpItem());
|
||||||
guiItemBuilder.addIngredient('D', new ScrollDownItem());
|
guiItemBuilder.addIngredient('D', new ScrollDownItem());
|
||||||
guiItemBuilder.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()));
|
guiItemBuilder.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()));
|
||||||
guiItemBuilder.setContent(items);
|
guiItemBuilder.setContent(items);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,15 @@ public class SettingsGUI {
|
||||||
dynamicStructure[1] = dynamicStructure[1].replace("T", "U");
|
dynamicStructure[1] = dynamicStructure[1].replace("T", "U");
|
||||||
|
|
||||||
final HomeGUI parent = new HomeGUI(player);
|
final HomeGUI parent = new HomeGUI(player);
|
||||||
|
final LanguageCyclingItem languageItem = new LanguageCyclingItem(player);
|
||||||
|
final BungeeCordCyclingItem bungeeCordItem = new BungeeCordCyclingItem(player);
|
||||||
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
||||||
this.gui = Gui.normal()
|
this.gui = Gui.normal()
|
||||||
.setStructure(dynamicStructure)
|
.setStructure(dynamicStructure)
|
||||||
.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()))
|
.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()))
|
||||||
.addIngredient('L', new LanguageCyclingItem().get(player))
|
.addIngredient('L', languageItem.get())
|
||||||
.addIngredient('T', new BungeeCordCyclingItem().get(player))
|
.addIngredient('T', bungeeCordItem.get())
|
||||||
.build();
|
.build();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,30 @@
|
||||||
package xyz.atnrch.nicko.gui.items.common;
|
package xyz.atnrch.nicko.gui.items.common;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
|
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||||
import xyz.xenondevs.invui.gui.Gui;
|
import xyz.xenondevs.invui.gui.Gui;
|
||||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||||
import xyz.xenondevs.invui.window.Window;
|
import xyz.xenondevs.invui.window.Window;
|
||||||
|
|
||||||
public class GoBackItem extends SuppliedItem {
|
public class GoBackItem {
|
||||||
public GoBackItem(Gui gui, String parentTitle) {
|
private final Player player;
|
||||||
super(() -> {
|
private final I18N i18n;
|
||||||
|
|
||||||
|
public GoBackItem(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
this.i18n = new I18N(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuppliedItem get(Gui gui, String parentTitle) {
|
||||||
|
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.GO_BACK);
|
||||||
|
return new SuppliedItem(() -> {
|
||||||
final ItemBuilder builder = new ItemBuilder(Material.ARROW);
|
final ItemBuilder builder = new ItemBuilder(Material.ARROW);
|
||||||
builder.setDisplayName("Go back");
|
builder.setDisplayName(translation.getName());
|
||||||
builder.addLoreLines("§7Return to the previous window.");
|
translation.getLore().forEach(builder::addLoreLines);
|
||||||
return builder;
|
return builder;
|
||||||
}, click -> {
|
}, click -> {
|
||||||
click.getEvent().getView().close();
|
click.getEvent().getView().close();
|
||||||
|
|
|
@ -14,8 +14,4 @@ public class ExitItem extends SimpleItem {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder getItemBuilder() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package xyz.atnrch.nicko.gui.items.settings;
|
package xyz.atnrch.nicko.gui.items.settings;
|
||||||
|
|
||||||
import xyz.atnrch.nicko.NickoBukkit;
|
import xyz.atnrch.nicko.NickoBukkit;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
|
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
@ -14,12 +17,20 @@ import xyz.xenondevs.invui.item.impl.SimpleItem;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class BungeeCordCyclingItem {
|
public class BungeeCordCyclingItem {
|
||||||
private final ItemProvider[] providers = new ItemProvider[]{
|
private final Player player;
|
||||||
getItemProviderForValue(true),
|
private final I18N i18n;
|
||||||
getItemProviderForValue(false)
|
private final ItemProvider[] providers;
|
||||||
};
|
|
||||||
|
|
||||||
public AbstractItem get(Player player) {
|
public BungeeCordCyclingItem(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
this.i18n = new I18N(player);
|
||||||
|
this.providers = new ItemProvider[]{
|
||||||
|
getItemProviderForValue(true),
|
||||||
|
getItemProviderForValue(false)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractItem get() {
|
||||||
final Optional<NickoProfile> profile = NickoBukkit.getInstance().getDataStore().getData(player.getUniqueId());
|
final Optional<NickoProfile> profile = NickoBukkit.getInstance().getDataStore().getData(player.getUniqueId());
|
||||||
if (profile.isPresent()) {
|
if (profile.isPresent()) {
|
||||||
final NickoProfile nickoProfile = profile.get();
|
final NickoProfile nickoProfile = profile.get();
|
||||||
|
@ -35,7 +46,9 @@ public class BungeeCordCyclingItem {
|
||||||
|
|
||||||
private ItemProvider getItemProviderForValue(boolean enabled) {
|
private ItemProvider getItemProviderForValue(boolean enabled) {
|
||||||
final ItemBuilder builder = new ItemBuilder(Material.COMPASS);
|
final ItemBuilder builder = new ItemBuilder(Material.COMPASS);
|
||||||
builder.setDisplayName("BungeeCord transfer");
|
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Settings.BUNGEECORD);
|
||||||
|
|
||||||
|
builder.setDisplayName(translation.getName());
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
builder.addLoreLines("§7> §cDisabled");
|
builder.addLoreLines("§7> §cDisabled");
|
||||||
builder.addLoreLines("§6§l> §a§lEnabled");
|
builder.addLoreLines("§6§l> §a§lEnabled");
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||||
import xyz.atnrch.nicko.NickoBukkit;
|
import xyz.atnrch.nicko.NickoBukkit;
|
||||||
import xyz.atnrch.nicko.i18n.I18N;
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
|
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||||
import xyz.atnrch.nicko.i18n.Locale;
|
import xyz.atnrch.nicko.i18n.Locale;
|
||||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||||
|
@ -21,9 +22,17 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class LanguageCyclingItem {
|
public class LanguageCyclingItem {
|
||||||
private final ItemProvider[] providers = getItems();
|
private final Player player;
|
||||||
|
private final ItemProvider[] providers;
|
||||||
|
private final I18N i18n;
|
||||||
|
|
||||||
public AbstractItem get(Player player) {
|
public LanguageCyclingItem(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
this.i18n = new I18N(player);
|
||||||
|
this.providers = getItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractItem get() {
|
||||||
final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
|
final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
|
||||||
final Optional<NickoProfile> profile = dataStore.getData(player.getUniqueId());
|
final Optional<NickoProfile> profile = dataStore.getData(player.getUniqueId());
|
||||||
if (profile.isPresent()) {
|
if (profile.isPresent()) {
|
||||||
|
@ -46,7 +55,9 @@ public class LanguageCyclingItem {
|
||||||
|
|
||||||
private ItemProvider generateItem(Locale locale, List<Locale> locales) {
|
private ItemProvider generateItem(Locale locale, List<Locale> locales) {
|
||||||
final ItemBuilder builder = new ItemBuilder(Material.OAK_SIGN);
|
final ItemBuilder builder = new ItemBuilder(Material.OAK_SIGN);
|
||||||
builder.setDisplayName("Language");
|
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Settings.LANGUAGE);
|
||||||
|
|
||||||
|
builder.setDisplayName(translation.getName());
|
||||||
for (Locale value : locales) {
|
for (Locale value : locales) {
|
||||||
if (locale != value) {
|
if (locale != value) {
|
||||||
builder.addLoreLines("§7> " + value.getName());
|
builder.addLoreLines("§7> " + value.getName());
|
||||||
|
@ -61,8 +72,8 @@ public class LanguageCyclingItem {
|
||||||
private ItemProvider[] getItems() {
|
private ItemProvider[] getItems() {
|
||||||
final NickoBukkit instance = NickoBukkit.getInstance();
|
final NickoBukkit instance = NickoBukkit.getInstance();
|
||||||
final ArrayList<ItemProvider> items = new ArrayList<>();
|
final ArrayList<ItemProvider> items = new ArrayList<>();
|
||||||
|
|
||||||
final ArrayList<Locale> localesToGenerate = new ArrayList<>();
|
final ArrayList<Locale> localesToGenerate = new ArrayList<>();
|
||||||
|
|
||||||
Collections.addAll(localesToGenerate, Locale.values());
|
Collections.addAll(localesToGenerate, Locale.values());
|
||||||
if (!instance.getNickoConfig().isCustomLocale()) {
|
if (!instance.getNickoConfig().isCustomLocale()) {
|
||||||
localesToGenerate.remove(Locale.CUSTOM);
|
localesToGenerate.remove(Locale.CUSTOM);
|
||||||
|
|
|
@ -8,8 +8,7 @@ import xyz.atnrch.nicko.appearance.AppearanceManager;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class I18N {
|
public class I18N {
|
||||||
private final MessageFormat formatter = new MessageFormat("");
|
private final MessageFormat formatter = new MessageFormat("");
|
||||||
|
@ -30,19 +29,31 @@ public class I18N {
|
||||||
this.yamlConfig = getYamlConfig();
|
this.yamlConfig = getYamlConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> translateItem(String key, Object... arguments) {
|
public ItemTranslation translateItem(String key, String... args) {
|
||||||
final ArrayList<String> lines = new ArrayList<>();
|
final String name = readString(key + ".name");
|
||||||
final String itemNameKey = readString(key + ".name");
|
final ArrayList<String> lore = readList(key + ".lore");
|
||||||
final ArrayList<String> itemLoreKey = readList(key + ".lore");
|
|
||||||
try {
|
// Add all elements to a list
|
||||||
// Item Name
|
final ArrayList<String> toTranslate = new ArrayList<>();
|
||||||
formatter.applyPattern(itemNameKey);
|
toTranslate.add(name);
|
||||||
final String itemNameTranslated = formatter.format(arguments);
|
toTranslate.addAll(lore);
|
||||||
lines.add(itemNameTranslated);
|
|
||||||
return lines;
|
// Set starting index to 0
|
||||||
} catch (Exception e) {
|
int index = 0;
|
||||||
return Collections.singletonList(key);
|
|
||||||
|
// While iterator next value exists/isn't null
|
||||||
|
final Iterator<String> iterator = toTranslate.iterator();
|
||||||
|
while (!iterator.hasNext() || iterator.next() == null) {
|
||||||
|
// Get the current line
|
||||||
|
final String currentLine = toTranslate.get(index);
|
||||||
|
|
||||||
|
// Replace with the corresponding varargs index
|
||||||
|
toTranslate.set(index, currentLine.replace("{" + index + "}", args[index]));
|
||||||
|
|
||||||
|
// Increment the index
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
|
return new ItemTranslation(toTranslate.get(0), toTranslate.subList(1, toTranslate.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String translate(String key, Object... arguments) {
|
public String translate(String key, Object... arguments) {
|
||||||
|
|
|
@ -64,11 +64,21 @@ public class I18NDict {
|
||||||
private static final String GUI_KEY = "gui.";
|
private static final String GUI_KEY = "gui.";
|
||||||
|
|
||||||
public static final String EXIT = GUI_KEY + "exit";
|
public static final String EXIT = GUI_KEY + "exit";
|
||||||
|
public static final String GO_BACK = GUI_KEY + "go_back";
|
||||||
|
|
||||||
public static class Home {
|
public static class Home {
|
||||||
private static final String HOME_KEY = GUI_KEY + "home.";
|
private static final String HOME_KEY = GUI_KEY + "home.";
|
||||||
|
|
||||||
public static final String ADMIN = HOME_KEY + "admin";
|
public static final String ADMIN = HOME_KEY + "admin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Settings {
|
||||||
|
private static final String SETTINGS_KEY = GUI_KEY + "settings.";
|
||||||
|
|
||||||
|
public static final String LANGUAGE = SETTINGS_KEY + "language";
|
||||||
|
public static final String BUNGEECORD = SETTINGS_KEY + "bungeecord";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
src/main/java/xyz/atnrch/nicko/i18n/ItemTranslation.java
Normal file
21
src/main/java/xyz/atnrch/nicko/i18n/ItemTranslation.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package xyz.atnrch.nicko.i18n;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ItemTranslation {
|
||||||
|
private final String name;
|
||||||
|
private final List<String> lore;
|
||||||
|
|
||||||
|
public ItemTranslation(String name, List<String> lore) {
|
||||||
|
this.name = name;
|
||||||
|
this.lore = lore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLore() {
|
||||||
|
return lore;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,38 +0,0 @@
|
||||||
package xyz.atnrch.nicko.i18n;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class ItemTranslator {
|
|
||||||
private final String name;
|
|
||||||
private final ArrayList<String> lore;
|
|
||||||
|
|
||||||
public ItemTranslator(String name, ArrayList<String> lore) {
|
|
||||||
this.name = name;
|
|
||||||
this.lore = lore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[] translate(String... args) {
|
|
||||||
// Add all elements to a list
|
|
||||||
final ArrayList<String> toTranslate = new ArrayList<>();
|
|
||||||
toTranslate.add(name);
|
|
||||||
toTranslate.addAll(lore);
|
|
||||||
|
|
||||||
// Set starting index to 0
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
// While iterator next value exists/isn't null
|
|
||||||
final Iterator<String> iterator = toTranslate.iterator();
|
|
||||||
while (!iterator.hasNext() || iterator.next() == null) {
|
|
||||||
// Get the current line
|
|
||||||
final String currentLine = toTranslate.get(index);
|
|
||||||
|
|
||||||
// Replace with the corresponding varargs index
|
|
||||||
toTranslate.set(index, currentLine.replace("{" + index + "}", args[index]));
|
|
||||||
|
|
||||||
// Increment the index
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
return new Object[]{toTranslate.get(0), toTranslate.subList(1, toTranslate.size())};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ public class LocaleFileManager {
|
||||||
public String getString(String key) {
|
public String getString(String key) {
|
||||||
if (!file.exists()) return key;
|
if (!file.exists()) return key;
|
||||||
try (BufferedInputStream inputStream = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
|
try (BufferedInputStream inputStream = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
|
||||||
final YamlConfig yamlConfig = YamlConfig.load(inputStream);
|
final YamlConfig yamlConfig = new YamlConfig(inputStream);
|
||||||
return yamlConfig.getString(key);
|
return yamlConfig.getString(key);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return key;
|
return key;
|
||||||
|
@ -44,7 +44,7 @@ public class LocaleFileManager {
|
||||||
public YamlConfig getYamlFile() {
|
public YamlConfig getYamlFile() {
|
||||||
if (yamlFile == null) {
|
if (yamlFile == null) {
|
||||||
try (BufferedInputStream inputStream = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
|
try (BufferedInputStream inputStream = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
|
||||||
yamlFile = YamlConfig.load(inputStream);
|
yamlFile = new YamlConfig(inputStream);
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,3 +55,8 @@ gui:
|
||||||
- "{0}"
|
- "{0}"
|
||||||
- "§7§oGet through the values"
|
- "§7§oGet through the values"
|
||||||
- "§7§oby left or right clicking."
|
- "§7§oby left or right clicking."
|
||||||
|
bungeecord:
|
||||||
|
name: "Bungeecord Transfer"
|
||||||
|
lore:
|
||||||
|
- "§7§oGet through the values"
|
||||||
|
- "§7§oby left or right clicking."
|
|
@ -31,15 +31,11 @@ gui:
|
||||||
admin:
|
admin:
|
||||||
name: "Panel d''administration"
|
name: "Panel d''administration"
|
||||||
lore:
|
lore:
|
||||||
length: 1
|
- "Configurez et gérez Nicko."
|
||||||
content:
|
|
||||||
- "Configurez et gérez Nicko."
|
|
||||||
settings:
|
settings:
|
||||||
name: "Paramètres"
|
name: "Paramètres"
|
||||||
lore:
|
lore:
|
||||||
length: 1
|
- "Configurez votre expérience."
|
||||||
content:
|
|
||||||
"Configurez votre expérience."
|
|
||||||
change_name:
|
change_name:
|
||||||
name: "Changer le §6pseudo"
|
name: "Changer le §6pseudo"
|
||||||
change_skin:
|
change_skin:
|
||||||
|
@ -52,9 +48,13 @@ gui:
|
||||||
- "Supprime complètement votre déguisement."
|
- "Supprime complètement votre déguisement."
|
||||||
settings:
|
settings:
|
||||||
language:
|
language:
|
||||||
name: "Language"
|
name: "Langage"
|
||||||
lore:
|
lore:
|
||||||
# The language values will be filled at {0}
|
|
||||||
- "{0}"
|
- "{0}"
|
||||||
- "§7§oParcourez les valeurs"
|
- "§7§oParcourez les valeurs"
|
||||||
- "§7§oavec un clique gauche/droit."
|
- "§7§oavec un clique gauche/droit."
|
||||||
|
bungeecord:
|
||||||
|
name: "Bungeecord Transfer"
|
||||||
|
lore:
|
||||||
|
- "§7§oGet through the values"
|
||||||
|
- "§7§oby left or right clicking."
|
|
@ -12,10 +12,9 @@ import xyz.atnrch.nicko.config.Configuration;
|
||||||
import xyz.atnrch.nicko.config.DataSourceConfiguration;
|
import xyz.atnrch.nicko.config.DataSourceConfiguration;
|
||||||
import xyz.atnrch.nicko.i18n.I18N;
|
import xyz.atnrch.nicko.i18n.I18N;
|
||||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
|
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||||
import xyz.atnrch.nicko.i18n.Locale;
|
import xyz.atnrch.nicko.i18n.Locale;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class I18NLoreTest {
|
public class I18NLoreTest {
|
||||||
private static NickoBukkit plugin;
|
private static NickoBukkit plugin;
|
||||||
private static PlayerMock player;
|
private static PlayerMock player;
|
||||||
|
@ -35,8 +34,9 @@ public class I18NLoreTest {
|
||||||
@DisplayName("Translate Item Lore")
|
@DisplayName("Translate Item Lore")
|
||||||
public void translateItemLore() {
|
public void translateItemLore() {
|
||||||
final I18N i18n = new I18N(Locale.FRENCH);
|
final I18N i18n = new I18N(Locale.FRENCH);
|
||||||
List<String> strings = i18n.translateItem(I18NDict.GUI.Home.ADMIN);
|
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.ADMIN);
|
||||||
System.out.println("strings = " + strings);
|
System.out.println("name = " + translation.getName());
|
||||||
|
System.out.println("lore = " + translation.getLore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
|
|
Loading…
Reference in a new issue