Fix wrong language codes displaying to user (#2880) (#2930)

* Updated language codes displayed for Hebrew, Indonesian and Yiddish (#2880)

* Function 'fixLanguageCode' encapsulated with unit tests (#2880)

* Renaming class "StringUtils" as "LangCodeUtils" and small String formatting improvement in "SpinnerLanguagesAdapter"
This commit is contained in:
Cesar Villalobos 2019-04-26 22:55:12 -06:00 committed by neslihanturan
parent d22884f86a
commit ee3f4d4d30
3 changed files with 56 additions and 5 deletions

View file

@ -0,0 +1,23 @@
package fr.free.nrw.commons.utils;
/**
* Utilities class for miscellaneous strings
*/
public class LangCodeUtils {
/**
* Replaces the deprecated ISO-639 language codes used by Android with the updated ISO-639-1.
* @param code Language code you want to update.
* @return Updated language code. If not in the "deprecated list" returns the same code.
*/
public static String fixLanguageCode(String code) {
if (code.equalsIgnoreCase("iw")) {
return "he";
} else if (code.equalsIgnoreCase("in")) {
return "id";
} else if (code.equalsIgnoreCase("ji")) {
return "yi";
} else {
return code;
}
}
}