Skip to content

Commit

Permalink
sanitized locale in Dict getters for #10
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLeoni committed Mar 4, 2016
1 parent a3a8797 commit 8b531df
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public Dict putTranslation(Locale locale, String string) {

@Nullable
public String getString(Locale locale) {
List<String> as = translations.get(locale);
List<String> as = translations.get(sanitizeLocale(locale));
if (as == null) {
return null;
}
Expand Down Expand Up @@ -230,14 +230,14 @@ private boolean isValid(String s) {
@Nullable
public String getValidTranslation(Locale locale) {
if (translations.containsKey(locale)) {
List<String> as = translations.get(locale);
List<String> as = translations.get(sanitizeLocale(locale));
if (as == null) {
return null;
}
if (as.isEmpty()) {
return null;
} else {
for (String s : translations.get(locale)) {
for (String s : translations.get(sanitizeLocale(locale))) {
if (isValid(s)) {
return s;
}
Expand All @@ -250,7 +250,7 @@ public String getValidTranslation(Locale locale) {

public List<String> getStrings(Locale locale) {
if (translations.containsKey(locale)) {
return translations.get(locale);
return translations.get(sanitizeLocale(locale));
} else {
return new ArrayList<String>();
}
Expand Down

0 comments on commit 8b531df

Please sign in to comment.