Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit c9bf79b

Browse files
committed
Added a Android-Drupal Locale mapping
1 parent c21c138 commit c9bf79b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.insready.drupalcloud;
2+
3+
/**
4+
*
5+
* Drupal uses RFC 4646 as the language tags standards, {@link https
6+
* ://www.drupal.org/node/923304#comment-3496864} while Android uses ISO 639-1
7+
* and ISO 3166-1 as the standard {@link http
8+
* ://developer.android.com/reference/java/util/Locale.html} Therefore, there
9+
* exists a need for such mapping.
10+
*/
11+
public final class LanguageMapping {
12+
13+
public final static String[] ANDROIDLOCALES = { "en_CA", "fr_CA", "zh_CN",
14+
"zh", "en", "fr_FR", "fr", "de", "de_DE", "it", "it_IT", "ja_JP",
15+
"ja", "ko_KR", "ko", "zh_CN", "zh_TW", "en_GB", "en_US" };
16+
17+
/**
18+
* DrupalLocales try to match AndroidLocales
19+
*/
20+
public final static String[] DRUPALLOCALES = { "en", "fr", "zh-hans",
21+
"zh-hans", "en", "fr", "fr", "de", "de", "it", "it", "ja", "ja",
22+
"ko", "zh-hans", "zh-hant", "en-gb", "en" };
23+
24+
public static int findAndroidLocaleIndex(String locale_code) {
25+
int size = ANDROIDLOCALES.length;
26+
for (int i = 0; i < size; i++) {
27+
if (ANDROIDLOCALES[i].equals(locale_code))
28+
return i;
29+
}
30+
return -1;
31+
}
32+
}

0 commit comments

Comments
 (0)