This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed translation argument translation
- Loading branch information
Showing
10 changed files
with
86 additions
and
44 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/net/catharos/societies/StringDictionary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.catharos.societies; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.name.Named; | ||
import net.catharos.lib.core.i18n.DefaultDictionary; | ||
import net.catharos.societies.bridge.ChatColor; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* Represents a StringDictionary | ||
*/ | ||
public class StringDictionary extends DefaultDictionary<String> { | ||
|
||
@Inject | ||
public StringDictionary(@Named("default-locale") Locale defaultLocale) { | ||
super(defaultLocale); | ||
} | ||
|
||
@Override | ||
public String getTranslation(String key, String locale, Object... args) { | ||
translateArguments(args); | ||
ChatColor.argumentColorReset(args); | ||
return super.getTranslation(key, locale, args); | ||
} | ||
|
||
private void translateArguments(Object... args) { | ||
for (int i = 0, length = args.length; i < length; i++) { | ||
Object arg = args[i]; | ||
|
||
if (arg instanceof String) { | ||
if (((String) arg).startsWith(":")) { | ||
args[i] = getTranslation(((String) arg).substring(1)); | ||
} | ||
|
||
args[i] = args[i] + ChatColor.RESET.toString(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ authors: | |
- p000ison | ||
commands: | ||
society: | ||
aliases: [ societies, s ] | ||
description: Society main command | ||
usage: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters