refactor(i18n): optimizations
This commit is contained in:
parent
ba9f39659b
commit
aa9b71bc18
19 changed files with 46 additions and 54 deletions
|
@ -45,7 +45,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
implementation("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
|
||||||
implementation("com.comphenix.protocol:ProtocolLib:5.1.1-SNAPSHOT")
|
implementation("com.comphenix.protocol:ProtocolLib:5.1.1-SNAPSHOT")
|
||||||
|
|
||||||
shadowImplementation("me.clip:placeholderapi:2.11.4")
|
shadowImplementation("me.clip:placeholderapi:2.11.4")
|
||||||
|
@ -132,6 +132,8 @@ tasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
|
||||||
downloadPlugins {
|
downloadPlugins {
|
||||||
url("https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar")
|
url("https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar")
|
||||||
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
||||||
|
|
|
@ -115,9 +115,14 @@ public class AnvilManager {
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
final ActionResult actionResult = appearanceManager.updatePlayer(skinChange, false);
|
final ActionResult actionResult = appearanceManager.updatePlayer(skinChange, false);
|
||||||
if (!actionResult.isError()) {
|
if (!actionResult.isError()) {
|
||||||
player.sendMessage(i18n.translateString(I18NDict.Event.Appearance.Set.OK));
|
player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Set.OK, true));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(i18n.translateString(I18NDict.Event.Appearance.Set.ERROR, i18n.translateStringWithoutPrefix(actionResult.getErrorKey())));
|
player.sendMessage(
|
||||||
|
i18n.translate(
|
||||||
|
I18NDict.Event.Appearance.Set.ERROR,
|
||||||
|
true,
|
||||||
|
i18n.translate(actionResult.getErrorKey(), false)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return Collections.singletonList(AnvilGUI.ResponseAction.close());
|
return Collections.singletonList(AnvilGUI.ResponseAction.close());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,13 @@ public class PlayerJoinListener implements Listener {
|
||||||
final boolean needsASkinChange = profile.getSkin() != null && !profile.getSkin().equals(player.getName());
|
final boolean needsASkinChange = profile.getSkin() != null && !profile.getSkin().equals(player.getName());
|
||||||
final ActionResult actionResult = appearanceManager.updatePlayer(needsASkinChange, false);
|
final ActionResult actionResult = appearanceManager.updatePlayer(needsASkinChange, false);
|
||||||
if (!actionResult.isError()) {
|
if (!actionResult.isError()) {
|
||||||
player.sendMessage(i18n.translateString(I18NDict.Event.Appearance.Restore.OK));
|
player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Restore.OK, true));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(i18n.translateString(I18NDict.Event.Appearance.Restore.ERROR, i18n.translateStringWithoutPrefix(actionResult.getErrorKey())));
|
player.sendMessage(
|
||||||
|
i18n.translate(I18NDict.Event.Appearance.Restore.ERROR,
|
||||||
|
true,
|
||||||
|
i18n.translate(actionResult.getErrorKey(), false)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class AdminGUI {
|
||||||
|
|
||||||
public AdminGUI(Player player) {
|
public AdminGUI(Player player) {
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.ADMIN);
|
this.title = i18n.translate(I18NDict.GUI.Titles.ADMIN, false);
|
||||||
|
|
||||||
final HomeGUI parent = new HomeGUI(player);
|
final HomeGUI parent = new HomeGUI(player);
|
||||||
final GoBackItem backItem = new GoBackItem(player);
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class CacheManagementGUI {
|
||||||
|
|
||||||
public CacheManagementGUI(Player player) {
|
public CacheManagementGUI(Player player) {
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.CACHE);
|
this.title = i18n.translate(I18NDict.GUI.Titles.CACHE, false);
|
||||||
|
|
||||||
final AdminGUI parent = new AdminGUI(player);
|
final AdminGUI parent = new AdminGUI(player);
|
||||||
final GoBackItem backItem = new GoBackItem(player);
|
final GoBackItem backItem = new GoBackItem(player);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class ChoiceGUI {
|
||||||
final ConfirmItem confirmItem = new ConfirmItem(player, callback);
|
final ConfirmItem confirmItem = new ConfirmItem(player, callback);
|
||||||
final CancelItem cancelItem = new CancelItem(player, callback);
|
final CancelItem cancelItem = new CancelItem(player, callback);
|
||||||
|
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.CONFIRM);
|
this.title = i18n.translate(I18NDict.GUI.Titles.CONFIRM, false);
|
||||||
this.gui = Gui.normal()
|
this.gui = Gui.normal()
|
||||||
.setStructure(
|
.setStructure(
|
||||||
"@ @ @ @ % & & & &",
|
"@ @ @ @ % & & & &",
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class HomeGUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.HOME);
|
this.title = i18n.translate(I18NDict.GUI.Titles.HOME, false);
|
||||||
|
|
||||||
final ExitItem exitItem = new ExitItem(player);
|
final ExitItem exitItem = new ExitItem(player);
|
||||||
final ResetItem resetItem = new ResetItem(player);
|
final ResetItem resetItem = new ResetItem(player);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class InvalidateSkinGUI {
|
||||||
|
|
||||||
public InvalidateSkinGUI(Player player) {
|
public InvalidateSkinGUI(Player player) {
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.INVALIDATE_SKIN);
|
this.title = i18n.translate(I18NDict.GUI.Titles.INVALIDATE_SKIN, false);
|
||||||
|
|
||||||
final ConcurrentMap<String, Optional<MojangSkin>> skins = NickoBukkit.getInstance().getMojangAPI().getSkinCache().asMap();
|
final ConcurrentMap<String, Optional<MojangSkin>> skins = NickoBukkit.getInstance().getMojangAPI().getSkinCache().asMap();
|
||||||
final List<String> loadedSkins = skins.entrySet().stream()
|
final List<String> loadedSkins = skins.entrySet().stream()
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class PlayerCheckGUI {
|
||||||
|
|
||||||
public PlayerCheckGUI(Player player, Collection<? extends Player> players) {
|
public PlayerCheckGUI(Player player, Collection<? extends Player> players) {
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.CHECK);
|
this.title = i18n.translate(I18NDict.GUI.Titles.CHECK, false);
|
||||||
|
|
||||||
final List<Item> items = players.stream()
|
final List<Item> items = players.stream()
|
||||||
.map(Entity::getUniqueId)
|
.map(Entity::getUniqueId)
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class SettingsGUI {
|
||||||
};
|
};
|
||||||
|
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
this.title = i18n.translateStringWithoutPrefix(I18NDict.GUI.Titles.SETTINGS);
|
this.title = i18n.translate(I18NDict.GUI.Titles.SETTINGS, false);
|
||||||
|
|
||||||
final HomeGUI parent = new HomeGUI(player);
|
final HomeGUI parent = new HomeGUI(player);
|
||||||
final LanguageCyclingItem languageItem = new LanguageCyclingItem(player);
|
final LanguageCyclingItem languageItem = new LanguageCyclingItem(player);
|
||||||
|
|
|
@ -29,7 +29,9 @@ public class CacheEntryItem extends AsyncItem {
|
||||||
|
|
||||||
public CacheEntryItem(I18N i18n, String uuid) {
|
public CacheEntryItem(I18N i18n, String uuid) {
|
||||||
super(new ItemBuilder(Material.PAINTING)
|
super(new ItemBuilder(Material.PAINTING)
|
||||||
.setDisplayName(Component.text(i18n.translateStringWithoutPrefix(I18NDict.GUI.LOADING)).content()),
|
.setDisplayName(
|
||||||
|
Component.text(i18n.translate(I18NDict.GUI.LOADING, false)).content()
|
||||||
|
),
|
||||||
() -> {
|
() -> {
|
||||||
final String dashedUuid = uuid.replaceAll("(.{8})(.{4})(.{4})(.{4})(.+)", "$1-$2-$3-$4-$5");
|
final String dashedUuid = uuid.replaceAll("(.{8})(.{4})(.{4})(.{4})(.+)", "$1-$2-$3-$4-$5");
|
||||||
final UUID uuidObject = UUID.fromString(dashedUuid);
|
final UUID uuidObject = UUID.fromString(dashedUuid);
|
||||||
|
@ -53,7 +55,7 @@ public class CacheEntryItem extends AsyncItem {
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm() {
|
public void onConfirm() {
|
||||||
final I18N i18n = new I18N(player);
|
final I18N i18n = new I18N(player);
|
||||||
player.sendMessage(i18n.translateString(I18NDict.Event.Admin.Cache.INVALIDATE_ENTRY, name));
|
player.sendMessage(i18n.translate(I18NDict.Event.Admin.Cache.INVALIDATE_ENTRY, true, name));
|
||||||
mojangAPI.eraseFromCache(uuid);
|
mojangAPI.eraseFromCache(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class PlayerInformationItem extends AsyncItem {
|
||||||
public void onConfirm() {
|
public void onConfirm() {
|
||||||
final AppearanceManager appearanceManager = new AppearanceManager(target);
|
final AppearanceManager appearanceManager = new AppearanceManager(target);
|
||||||
appearanceManager.reset();
|
appearanceManager.reset();
|
||||||
player.sendMessage(i18n.translateString(I18NDict.Event.Admin.Check.REMOVE_SKIN, target.getName()));
|
player.sendMessage(i18n.translate(I18NDict.Event.Admin.Check.REMOVE_SKIN, true, target.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ScrollDownItem extends ScrollItem {
|
||||||
@Override
|
@Override
|
||||||
public ItemProvider getItemProvider(ScrollGui gui) {
|
public ItemProvider getItemProvider(ScrollGui gui) {
|
||||||
final ItemBuilder builder = new ItemBuilder(Material.GREEN_STAINED_GLASS_PANE);
|
final ItemBuilder builder = new ItemBuilder(Material.GREEN_STAINED_GLASS_PANE);
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_DOWN);
|
final Translation translation = i18n.translateAndReplace(I18NDict.GUI.SCROLL_DOWN);
|
||||||
builder.setDisplayName(Component.text(translation.name()).content());
|
builder.setDisplayName(Component.text(translation.name()).content());
|
||||||
if (!gui.canScroll(1)) {
|
if (!gui.canScroll(1)) {
|
||||||
// Lore serialization
|
// Lore serialization
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ScrollUpItem extends ScrollItem {
|
||||||
@Override
|
@Override
|
||||||
public ItemProvider getItemProvider(ScrollGui gui) {
|
public ItemProvider getItemProvider(ScrollGui gui) {
|
||||||
final ItemBuilder builder = new ItemBuilder(Material.RED_STAINED_GLASS_PANE);
|
final ItemBuilder builder = new ItemBuilder(Material.RED_STAINED_GLASS_PANE);
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_UP);
|
final Translation translation = i18n.translateAndReplace(I18NDict.GUI.SCROLL_UP);
|
||||||
builder.setDisplayName(Component.text(translation.name()).content());
|
builder.setDisplayName(Component.text(translation.name()).content());
|
||||||
if (!gui.canScroll(-1)) {
|
if (!gui.canScroll(-1)) {
|
||||||
// Lore serialization
|
// Lore serialization
|
||||||
|
|
|
@ -59,8 +59,8 @@ 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);
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.Settings.LANGUAGE);
|
final Translation translation = i18n.translateAndReplace(I18NDict.GUI.Settings.LANGUAGE);
|
||||||
final Translation cyclingChoicesTranslation = i18n.translate(I18NDict.GUI.Settings.CYCLING_CHOICES);
|
final Translation cyclingChoicesTranslation = i18n.translateAndReplace(I18NDict.GUI.Settings.CYCLING_CHOICES);
|
||||||
|
|
||||||
builder.setDisplayName(Component.text(translation.name()).content());
|
builder.setDisplayName(Component.text(translation.name()).content());
|
||||||
for (Locale value : locales) {
|
for (Locale value : locales) {
|
||||||
|
|
|
@ -55,12 +55,12 @@ public class RandomSkinCyclingItem {
|
||||||
private ItemProvider getItemProviderForValue(boolean enabled) {
|
private ItemProvider getItemProviderForValue(boolean enabled) {
|
||||||
final SkullBuilder.HeadTexture texture = new SkullBuilder.HeadTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzgzMTEzOGMyMDYxMWQzMDJjNDIzZmEzMjM3MWE3NDNkMTc0MzdhMTg5NzNjMzUxOTczNDQ3MGE3YWJiNCJ9fX0=");
|
final SkullBuilder.HeadTexture texture = new SkullBuilder.HeadTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzgzMTEzOGMyMDYxMWQzMDJjNDIzZmEzMjM3MWE3NDNkMTc0MzdhMTg5NzNjMzUxOTczNDQ3MGE3YWJiNCJ9fX0=");
|
||||||
final SkullBuilder builder = new SkullBuilder(texture);
|
final SkullBuilder builder = new SkullBuilder(texture);
|
||||||
final Translation randomSkinTranslation = i18n.translate(I18NDict.GUI.Settings.RANDOM_SKIN);
|
final Translation randomSkinTranslation = i18n.translateAndReplace(I18NDict.GUI.Settings.RANDOM_SKIN);
|
||||||
final Translation toggleableTranslation = i18n.translate(I18NDict.GUI.Settings.TOGGLEABLE_BUTTON,
|
final Translation toggleableTranslation = i18n.translateAndReplace(I18NDict.GUI.Settings.TOGGLEABLE_BUTTON,
|
||||||
(enabled ? "§7>§c" : "§6§l>§c§l"),
|
(enabled ? "§7>§c" : "§6§l>§c§l"),
|
||||||
(enabled ? "§6§l>§a§l" : "§7>§a")
|
(enabled ? "§6§l>§a§l" : "§7>§a")
|
||||||
);
|
);
|
||||||
final Translation cyclingChoicesTranslation = i18n.translate(I18NDict.GUI.Settings.CYCLING_CHOICES);
|
final Translation cyclingChoicesTranslation = i18n.translateAndReplace(I18NDict.GUI.Settings.CYCLING_CHOICES);
|
||||||
|
|
||||||
builder.setDisplayName(randomSkinTranslation.name());
|
builder.setDisplayName(randomSkinTranslation.name());
|
||||||
toggleableTranslation.lore().forEach(builder::addLoreLines);
|
toggleableTranslation.lore().forEach(builder::addLoreLines);
|
||||||
|
|
|
@ -22,23 +22,21 @@ public class I18N {
|
||||||
private final NickoBukkit instance = NickoBukkit.getInstance();
|
private final NickoBukkit instance = NickoBukkit.getInstance();
|
||||||
private final Pattern replacementPattern = Pattern.compile("(?ms)\\{\\d+}");
|
private final Pattern replacementPattern = Pattern.compile("(?ms)\\{\\d+}");
|
||||||
private final YamlConfig yamlConfig;
|
private final YamlConfig yamlConfig;
|
||||||
private final Player player;
|
|
||||||
private final Locale playerLocale;
|
private final Locale playerLocale;
|
||||||
|
|
||||||
public I18N(Player player) {
|
public I18N(Player player) {
|
||||||
this.player = player;
|
final Optional<NickoProfile> optionalProfile = NickoProfile.get(player);
|
||||||
this.playerLocale = getPlayerLocale();
|
this.playerLocale = optionalProfile.map(NickoProfile::getLocale).orElse(Locale.ENGLISH);
|
||||||
this.yamlConfig = getYamlConfig();
|
this.yamlConfig = getYamlConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public I18N(Locale locale) {
|
public I18N(Locale locale) {
|
||||||
this.player = null;
|
|
||||||
this.playerLocale = locale;
|
this.playerLocale = locale;
|
||||||
this.yamlConfig = getYamlConfig();
|
this.yamlConfig = getYamlConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractItemBuilder<?> translateItem(AbstractItemBuilder<?> item, String key, Object... args) {
|
public AbstractItemBuilder<?> translateItem(AbstractItemBuilder<?> item, String key, Object... args) {
|
||||||
final Translation translation = translate(key, args);
|
final Translation translation = translateAndReplace(key, args);
|
||||||
|
|
||||||
// Name serialization
|
// Name serialization
|
||||||
final Component deserializedName = MiniMessage.miniMessage().deserialize(translation.name());
|
final Component deserializedName = MiniMessage.miniMessage().deserialize(translation.name());
|
||||||
|
@ -55,7 +53,7 @@ public class I18N {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Translation translate(String key, Object... args) {
|
public Translation translateAndReplace(String key, Object... args) {
|
||||||
final String nameKey = key + ".name";
|
final String nameKey = key + ".name";
|
||||||
final String loreKey = key + ".lore";
|
final String loreKey = key + ".lore";
|
||||||
final String name = readString(nameKey);
|
final String name = readString(nameKey);
|
||||||
|
@ -115,23 +113,13 @@ public class I18N {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String translateString(String key, Object... arguments) {
|
public String translate(String key, boolean prefix, Object... arguments) {
|
||||||
final String translation = readString(key);
|
final String translation = readString(key);
|
||||||
try {
|
try {
|
||||||
formatter.applyPattern(translation);
|
formatter.applyPattern(translation);
|
||||||
return instance.getNickoConfig().getPrefix() + formatter.format(arguments);
|
return (prefix ? instance.getNickoConfig().getPrefix() : "") + formatter.format(arguments);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return instance.getNickoConfig().getPrefix() + key;
|
return (prefix ? instance.getNickoConfig().getPrefix() : "") + key;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String translateStringWithoutPrefix(String key, Object... arguments) {
|
|
||||||
final String translation = readString(key);
|
|
||||||
try {
|
|
||||||
formatter.applyPattern(translation);
|
|
||||||
return formatter.format(arguments);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return key;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,13 +139,4 @@ public class I18N {
|
||||||
return new YamlConfig(resource);
|
return new YamlConfig(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getPlayerLocale() {
|
|
||||||
final Optional<NickoProfile> optionalProfile = NickoProfile.get(player);
|
|
||||||
if (optionalProfile.isPresent()) {
|
|
||||||
return optionalProfile.get().getLocale();
|
|
||||||
} else {
|
|
||||||
return Locale.ENGLISH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ItemTranslationTest {
|
||||||
@DisplayName("Translate Item Without Lore")
|
@DisplayName("Translate Item Without Lore")
|
||||||
public void translateItemTranslationWithoutLore() {
|
public void translateItemTranslationWithoutLore() {
|
||||||
final I18N i18n = new I18N(Locale.FRENCH);
|
final I18N i18n = new I18N(Locale.FRENCH);
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.GO_BACK);
|
final Translation translation = i18n.translateAndReplace(I18NDict.GUI.GO_BACK);
|
||||||
assertTrue(translation.lore().isEmpty());
|
assertTrue(translation.lore().isEmpty());
|
||||||
assertEquals(translation.name(), "Retour");
|
assertEquals(translation.name(), "Retour");
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,10 @@ public class ItemTranslationTest {
|
||||||
public void translateItemLore() {
|
public void translateItemLore() {
|
||||||
final I18N i18n = new I18N(Locale.FRENCH);
|
final I18N i18n = new I18N(Locale.FRENCH);
|
||||||
|
|
||||||
final Translation test = i18n.translate(I18NDict.GUI.Settings.TOGGLEABLE_BUTTON, "EST", "EST");
|
final Translation test = i18n.translateAndReplace(I18NDict.GUI.Settings.TOGGLEABLE_BUTTON, "EST", "EST");
|
||||||
test.lore().forEach(System.out::println);
|
test.lore().forEach(System.out::println);
|
||||||
|
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.Admin.Cache.STATISTICS, "1", "1");
|
final Translation translation = i18n.translateAndReplace(I18NDict.GUI.Admin.Cache.STATISTICS, "1", "1");
|
||||||
assertFalse(translation.lore().isEmpty());
|
assertFalse(translation.lore().isEmpty());
|
||||||
assertEquals("Nombre de requêtes: <aqua>1</aqua>", translation.lore().get(0));
|
assertEquals("Nombre de requêtes: <aqua>1</aqua>", translation.lore().get(0));
|
||||||
assertEquals("Nb. de skin dans le cache: <aqua>1</aqua>", translation.lore().get(1));
|
assertEquals("Nb. de skin dans le cache: <aqua>1</aqua>", translation.lore().get(1));
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class TranslationTest {
|
||||||
@DisplayName("Translate Line With Replacement")
|
@DisplayName("Translate Line With Replacement")
|
||||||
public void translateItemTranslationWithoutLore() {
|
public void translateItemTranslationWithoutLore() {
|
||||||
final I18N i18n = new I18N(Locale.FRENCH);
|
final I18N i18n = new I18N(Locale.FRENCH);
|
||||||
final String translation = i18n.translateStringWithoutPrefix(I18NDict.Event.Settings.ERROR, "Test");
|
final String translation = i18n.translate(I18NDict.Event.Settings.ERROR, false, "Test");
|
||||||
assertEquals("§cImpossible de mettre à jour vos paramètres. §7§o(Test)", translation);
|
assertEquals("§cImpossible de mettre à jour vos paramètres. §7§o(Test)", translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue