updates to translations
This commit is contained in:
1 parent
1f5b06daa2
commit
1e39f6caa8
5 files changed
+152
-145
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package carpet.settings;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.utils.Translations;
|
||||
import carpet.utils.Messenger;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
@@ -12,6 +13,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static carpet.utils.Translations.tr;
|
||||
|
||||
public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
public final Field field;
|
||||
public final String name;
|
||||
@@ -225,4 +228,32 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
{
|
||||
return this.name + ": " + getAsString();
|
||||
}
|
||||
|
||||
private String translationKey()
|
||||
{
|
||||
return String.format("carpet.rule.%s.name", name);
|
||||
}
|
||||
|
||||
public String translatedName(){
|
||||
String key = translationKey();
|
||||
return Translations.hasTranslation(key) ? tr(key) + String.format(" (%s)", name): name;
|
||||
}
|
||||
|
||||
public String translatedDescription()
|
||||
{
|
||||
return tr(String.format("carpet.rule.%s.desc", (name)), description);
|
||||
}
|
||||
|
||||
public List<String> translatedExtras()
|
||||
{
|
||||
if (!Translations.hasTranslations()) return extraInfo;
|
||||
String keyBase = String.format("carpet.rule.%s.extra.", name);
|
||||
List<String> extras = new ArrayList<>();
|
||||
int i = 0;
|
||||
while (Translations.hasTranslation(keyBase+i))
|
||||
{
|
||||
extras.add(Translations.tr(keyBase+i));
|
||||
}
|
||||
return (extras.isEmpty()) ? extraInfo : extras;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user