Difference between revisions of "Internationalization"
From OpenKM Documentation
(Created page with 'It's good idea centralizing Internationalization in a single class package for all OpenKM extensions. For example if you want to internationalization to english and spanish you …') |
|||
Line 1: | Line 1: | ||
It's good idea centralizing Internationalization in a single class package for all OpenKM extensions. | It's good idea centralizing Internationalization in a single class package for all OpenKM extensions. | ||
− | For example if you want to internationalization to english and spanish you migh create two classes Lang_en_GB and Lang_es_ES | + | |
+ | For example if you want to '''internationalization to english and spanish''' you migh create two classes '''Lang_en_GB.java''' and '''Lang_es_ES.java''' | ||
+ | |||
<source lang="java"> | <source lang="java"> | ||
Line 19: | Line 21: | ||
} | } | ||
</source> | </source> | ||
+ | |||
Line 40: | Line 43: | ||
} | } | ||
</source> | </source> | ||
+ | |||
Revision as of 11:58, 23 June 2010
It's good idea centralizing Internationalization in a single class package for all OpenKM extensions.
For example if you want to internationalization to english and spanish you migh create two classes Lang_en_GB.java and Lang_es_ES.java
package com.openkm.extension.frontend.client.lang;
import java.util.HashMap;
public class Lang_en_GB {
public final static HashMap<String, String> lang;
static {
lang = new HashMap<String, String>();
// Download button
lang.put("download.button.tittle", "Download document");
}
package com.openkm.extension.frontend.client.lang;
import java.util.HashMap;
public class Lang_es_ES {
public final static HashMap<String, String> lang;
static {
lang = new HashMap<String, String>();
// Download button
lang.put("download.button.tittle", "Descargar documento");
// Download pdf button
lang.put("download.pdf.button.tittle", "Descargar documento como pdf");
}
}
package com.openkm.extension.frontend.client.lang;
import java.util.HashMap;
public class Lang {
// Languages
public static final String LANG_es_ES = "es-ES";
public static final String LANG_en_GB = "en-GB";
public static HashMap<String, String> getLang(String lang) {
HashMap<String, String> hLang = new HashMap<String, String>();
if (LANG_es_ES.equalsIgnoreCase(lang) || LANG_es_ES.substring(0, 2).equalsIgnoreCase(lang.substring(0, 2))) {
hLang = Lang_es_ES.lang;
} else if (LANG_en_GB.equalsIgnoreCase(lang) || LANG_en_GB.substring(0, 2).equalsIgnoreCase(lang.substring(0, 2))) {
hLang = Lang_en_GB.lang;
} else {
hLang = Lang_en_GB.lang;
}
return hLang;
}
}