simplified translations keys
This commit is contained in:
1 parent
68093ed54a
commit
74c62e5a13
5 files changed
+102
-96
No files matched your search
@@ -231,7 +231,7 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
|
||||
private String translationKey()
|
||||
{
|
||||
return String.format("carpet.rule.%s.name", name);
|
||||
return String.format("rule.%s.name", name);
|
||||
}
|
||||
|
||||
public String translatedName(){
|
||||
@@ -241,13 +241,13 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
|
||||
public String translatedDescription()
|
||||
{
|
||||
return tr(String.format("carpet.rule.%s.desc", (name)), description);
|
||||
return tr(String.format("rule.%s.desc", (name)), description);
|
||||
}
|
||||
|
||||
public List<String> translatedExtras()
|
||||
{
|
||||
if (!Translations.hasTranslations()) return extraInfo;
|
||||
String keyBase = String.format("carpet.rule.%s.extra.", name);
|
||||
String keyBase = String.format("rule.%s.extra.", name);
|
||||
List<String> extras = new ArrayList<>();
|
||||
int i = 0;
|
||||
while (Translations.hasTranslation(keyBase+i))
|
||||
|
||||
@@ -352,7 +352,7 @@ public class SettingsManager
|
||||
String ruleName = StringArgumentType.getString(ctx, "rule");
|
||||
ParsedRule<?> rule = getRule(ruleName);
|
||||
if (rule == null)
|
||||
throw new SimpleCommandExceptionType(Messenger.c("rb "+ tr("carpet.ui.statement.unknown_rule","Unknown rule")+": "+ruleName)).create();
|
||||
throw new SimpleCommandExceptionType(Messenger.c("rb "+ tr("ui.unknown_rule","Unknown rule")+": "+ruleName)).create();
|
||||
return rule;
|
||||
}
|
||||
|
||||
@@ -370,16 +370,16 @@ public class SettingsManager
|
||||
|
||||
literalargumentbuilder.executes((context)-> listAllSettings(context.getSource())).
|
||||
then(literal("list").
|
||||
executes( (c) -> listSettings(c.getSource(), String.format(tr("carpet.ui.statement.all_%s_settings","All %s Settings"), fancyName),
|
||||
executes( (c) -> listSettings(c.getSource(), String.format(tr("ui.all_%(mod)s_settings","All %s Settings"), fancyName),
|
||||
getRules())).
|
||||
then(literal("defaults").
|
||||
executes( (c)-> listSettings(c.getSource(),
|
||||
String.format(tr("carpet.ui.statement.current_%s_startup_settings_from_%s","Current %s Startup Settings from %s"), fancyName, (identifier+".conf")),
|
||||
String.format(tr("ui.current_%(mod)s_startup_settings_from_%(conf)s","Current %s Startup Settings from %s"), fancyName, (identifier+".conf")),
|
||||
findStartupOverrides()))).
|
||||
then(argument("tag",StringArgumentType.word()).
|
||||
suggests( (c, b)->suggestMatching(getCategories(), b)).
|
||||
executes( (c) -> listSettings(c.getSource(),
|
||||
String.format(tr("carpet.ui.statement.%s_settings_matching_'%s'","%s Settings matching \"%s\""), fancyName, tr("carpet.ui.category." + StringArgumentType.getString(c, "tag"),StringArgumentType.getString(c, "tag"))),
|
||||
String.format(tr("ui.%(mod)s_settings_matching_'%(query)s'","%s Settings matching \"%s\""), fancyName, tr("category." + StringArgumentType.getString(c, "tag"),StringArgumentType.getString(c, "tag"))),
|
||||
getRulesMatching(StringArgumentType.getString(c, "tag")))))).
|
||||
then(literal("removeDefault").
|
||||
requires(s -> !locked).
|
||||
@@ -414,7 +414,7 @@ public class SettingsManager
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
Messenger.m(source, "w "+ displayName +" "+ tr( "carpet.ui.statement.is_set_to","is set to")+": ","wb "+rule.getAsString());
|
||||
Messenger.m(source, "w "+ displayName +" "+ tr( "ui.is_set_to","is set to")+": ","wb "+rule.getAsString());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -425,17 +425,17 @@ public class SettingsManager
|
||||
rule.translatedExtras().forEach(s -> Messenger.m(player, "g "+s));
|
||||
|
||||
List<BaseText> tags = new ArrayList<>();
|
||||
tags.add(Messenger.c("w "+ tr("carpet.ui.statement.tags", "Tags")+": "));
|
||||
tags.add(Messenger.c("w "+ tr("ui.tags", "Tags")+": "));
|
||||
for (String t: rule.categories)
|
||||
{
|
||||
String translated = tr("carpet.ui.category." + t, t);
|
||||
String translated = tr("category." + t, t);
|
||||
tags.add(Messenger.c("c ["+ translated +"]", "^g "+ String.format(tr("list_all_%s_settings","list all %s settings"), translated),"!/"+identifier+" list "+t));
|
||||
tags.add(Messenger.c("w , "));
|
||||
}
|
||||
tags.remove(tags.size()-1);
|
||||
Messenger.m(player, tags.toArray(new Object[0]));
|
||||
|
||||
Messenger.m(player, "w "+ tr("carpet.ui.statement.current_value", "Current value")+": ",String.format("%s %s (%s value)",rule.getBoolValue()?"lb":"nb", rule.getAsString(),rule.isDefault()?"default":"modified"));
|
||||
Messenger.m(player, "w "+ tr("ui.current_value", "Current value")+": ",String.format("%s %s (%s value)",rule.getBoolValue()?"lb":"nb", rule.getAsString(),rule.isDefault()?"default":"modified"));
|
||||
List<BaseText> options = new ArrayList<>();
|
||||
options.add(Messenger.c("w Options: ", "y [ "));
|
||||
for (String o: rule.options)
|
||||
@@ -453,8 +453,8 @@ public class SettingsManager
|
||||
private int setRule(ServerCommandSource source, ParsedRule<?> rule, String newValue)
|
||||
{
|
||||
if (rule.set(source, newValue) != null)
|
||||
Messenger.m(source, "w "+rule.toString()+", ", "c ["+ tr("carpet.ui.statement.change_permanently","change permanently")+"?]",
|
||||
"^w "+String.format(tr("carpet.ui.statement.click_to_keep_the_settings_in_%s_to_save_across_restarts","Click to keep the settings in %s to save across restarts"), identifier+".conf"),
|
||||
Messenger.m(source, "w "+rule.toString()+", ", "c ["+ tr("ui.change_permanently","change permanently")+"?]",
|
||||
"^w "+String.format(tr("ui.click_to_keep_the_settings_in_%(conf)s_to_save_across_restarts","Click to keep the settings in %s to save across restarts"), identifier+".conf"),
|
||||
"?/"+identifier+" setDefault "+rule.name+" "+rule.getAsString());
|
||||
return 1;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ public class SettingsManager
|
||||
writeSettingsToConf(conf.getLeft()); // this may feels weird, but if conf
|
||||
// is locked, it will never reach this point.
|
||||
rule.set(source,stringValue);
|
||||
Messenger.m(source ,"gi "+String.format(tr("carpet.ui.statement.rule_%s_will_now_default_to_%s","rule %s will now default to %s"), rule.translatedName(), stringValue));
|
||||
Messenger.m(source ,"gi "+String.format(tr("ui.rule_%(rule)s_will_now_default_to_%(value)s","rule %s will now default to %s"), rule.translatedName(), stringValue));
|
||||
return 1;
|
||||
}
|
||||
// removes overrides of the default values in the file
|
||||
@@ -516,10 +516,10 @@ public class SettingsManager
|
||||
}
|
||||
String baseText = style + (brackets ? " [" : " ") + option + (brackets ? "]" : "");
|
||||
if (locked)
|
||||
return Messenger.c(baseText, "^g "+fancyName+" " + tr("carpet.ui.statement.settings_are_locked","settings are locked"));
|
||||
return Messenger.c(baseText, "^g "+fancyName+" " + tr("ui.settings_are_locked","settings are locked"));
|
||||
if (option.equalsIgnoreCase(rule.getAsString()))
|
||||
return Messenger.c(baseText);
|
||||
return Messenger.c(baseText, "^g "+ tr("carpet.ui.statement.switch_to","Switch to") +" " + option+(option.equalsIgnoreCase(rule.defaultAsString)?" (default)":""), "?/"+identifier+" " + rule.name + " " + option);
|
||||
return Messenger.c(baseText, "^g "+ tr("ui.switch_to","Switch to") +" " + option+(option.equalsIgnoreCase(rule.defaultAsString)?" (default)":""), "?/"+identifier+" " + rule.name + " " + option);
|
||||
}
|
||||
|
||||
private int listSettings(ServerCommandSource source, String title, Collection<ParsedRule<?>> settings_list)
|
||||
@@ -541,24 +541,25 @@ public class SettingsManager
|
||||
private int listAllSettings(ServerCommandSource source)
|
||||
{
|
||||
//listSettings(source, "Current "+fancyName+" Settings", getNonDefault());
|
||||
listSettings(source, String.format(tr("carpet.ui.statement.current_%s_settings","Current %s Settings"), fancyName), getNonDefault());
|
||||
listSettings(source, String.format(tr("ui.current_%(mod)s_settings","Current %s Settings"), fancyName), getNonDefault());
|
||||
|
||||
if (version != null)
|
||||
//Messenger.m(source, "g "+fancyName+" version: "+ version);
|
||||
Messenger.m(source, "g "+fancyName+" "+ tr("carpet.ui.statement.version", "version") + ": "+ version);
|
||||
Messenger.m(source, "g "+fancyName+" "+ tr("ui.version", "version") + ": "+ version);
|
||||
try
|
||||
{
|
||||
PlayerEntity player = source.getPlayer();
|
||||
List<Object> tags = new ArrayList<>();
|
||||
//tags.add("w Browse Categories:\n");
|
||||
tags.add("w " + tr("carpet.ui.statement.browse_categories", "Browse Categories") + ":\n");
|
||||
tags.add("w " + tr("ui.browse_categories", "Browse Categories") + ":\n");
|
||||
for (String t : getCategories())
|
||||
{
|
||||
String translated = tr("carpet.ui.category." + t, t);
|
||||
String translatedPlus = Translations.hasTranslation("carpet.ui.category." + t) ? tr("carpet.ui.category." + t, t) + String.format(" (%s)", t) : t;
|
||||
String catKey = "category." + t;
|
||||
String translated = tr(catKey, t);
|
||||
String translatedPlus = Translations.hasTranslation(catKey) ? String.format("%s (%s)",tr(catKey, t), t) : t;
|
||||
tags.add("c [" + translated +"]");
|
||||
//tags.add("^g list all " + translated + " settings");
|
||||
tags.add("^g " + String.format(tr("carpet.ui.statement.list_all_%s_settings","list all %s settings"), translatedPlus));
|
||||
tags.add("^g " + String.format(tr("ui.list_all_%(cat)s_settings","list all %s settings"), translatedPlus));
|
||||
tags.add("!/"+identifier+" list " + t);
|
||||
tags.add("w ");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user