summaryrefslogtreecommitdiffstats
path: root/logo
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2015-02-25 22:56:55 +0000
committerMarko Živković <[email protected]>2015-02-25 22:56:55 +0000
commita25b730c4d6679dae2a2a9b0489b70b0fc75d992 (patch)
treecc0e825f0f5a2a12c0e868c915b95306795ce1ad /logo
parent7132cc451b93b0443dcd71a3da4d5db41bedf5f8 (diff)
Introduce Enum LogoLanguage to handle programming language and Gui language separately
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@27 3b0d7934-f7ef-4143-9606-b51f2e2281fd
Diffstat (limited to 'logo')
-rw-r--r--logo/src/xlogo/storage/workspace/LogoLanguage.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/logo/src/xlogo/storage/workspace/LogoLanguage.java b/logo/src/xlogo/storage/workspace/LogoLanguage.java
new file mode 100644
index 0000000..342aa52
--- /dev/null
+++ b/logo/src/xlogo/storage/workspace/LogoLanguage.java
@@ -0,0 +1,76 @@
+package xlogo.storage.workspace;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+public enum LogoLanguage {
+ LANGUAGE_FRENCH(0, "French", "fr", "FR"),
+ LANGUAGE_ENGLISH(1, "English", "en", "US"),
+ LANGUAGE_ARABIC(2, "Arabic", "ar", "MA"),
+ LANGUAGE_SPANISH(3, "Spanish", "es", "ES"),
+ LANGUAGE_PORTUGAL(4, "Portuguese", "pt", "BR"),
+ LANGUAGE_ESPERANTO(5, "Esperanto", "eo", "EO"),
+ LANGUAGE_GERMAN(6, "German", "de", "DE"),
+ LANGUAGE_GALICIAN(7, "Galician","gl", "ES"),
+ LANGUAGE_ASTURIAN(8, "Asturian", "al", "ES"),
+ LANGUAGE_GREEK(9, "Greek", "el", "GR"),
+ LANGUAGE_ITALIAN(10, "Italian", "it", "IT"),
+ LANGUAGE_CATALAN(11, "Catalan", "ca", "ES"),
+ LANGUAGE_HUNGARIAN(12,"Hungarian", "hu", "HU");
+
+ private int value;
+ private String englishName;
+ private String languageCode;
+ private String countryCode;
+
+ private static Map<Integer, LogoLanguage> valueToLanguage;
+
+ private LogoLanguage(int value, String englishName, String languageCode, String countryCode) {
+ this.value = value;
+ this.englishName = englishName;
+ this.languageCode = languageCode;
+ this.countryCode = countryCode;
+ }
+
+ public static LogoLanguage getLanguage(int i) {
+ if (valueToLanguage == null)
+ initMapping();
+ return valueToLanguage.get(i);
+ }
+
+ public static void initMapping() {
+ valueToLanguage = new HashMap<Integer, LogoLanguage>();
+ for (LogoLanguage lang : values()) {
+ valueToLanguage.put(lang.value, lang);
+ }
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public String getEnglishName() {
+ return englishName;
+ }
+
+ /**
+ * return English name
+ */
+ @Override
+ public String toString() {
+ return getEnglishName();
+ }
+
+ public Locale getLocale() {
+ return new Locale(languageCode, countryCode);
+ }
+
+ public String getLanguageCode() {
+ return languageCode;
+ }
+
+ public String getCountryCode() {
+ return countryCode;
+ }
+}