Internationalization / i18n
An internationalization of texts can be realized by using maps. The language code is the key and the text is associated value:
{"language_code1":"lang1_text","language_code2":"lang2_text",....}
The following examples demonstrate this.
Android
final
String language_code=
"de"
;
final
Conference conference =
new
Conference();
Map<String, String> i18n_name =
new
HashMap<String,String>();
i18n_name.put(
"de"
,
"Wie benutze ich properties"
);
i18n_name.put(
"en"
,
"How to use properties"
);
conference.setI18n_name(i18n_name);
Map<String, String> i18ns_guests =
new
HashMap<String,String>();
i18ns_guests.put(
"de"
,
"Gastsprecher: John Doe"
);
i18ns_guests.put(
"en"
,
"Guest speaker: John Doe"
);
conference.setI18n_guests(i18ns_guests);
conference.saveAsync(
new
AOMEmptyCallback() {
@Override
public
void
isDone(ApiomatRequestException exception) {
//if exception != null an error occurred
if
(exception ==
null
) {
Log.i (
"Conference"
,conference.getI18n_name().get(language_code));
Log.i (
"Conference"
,conference.getI18n_guests().get(language_code));
}
}
});
JavaScript
var
LANGUAGE=
"de"
;
function
showConference (conference)
{
console.log(conference.getI18n_name()[LANGUAGE]);
console.log(conference.getI18n_guests()[LANGUAGE]);
}
function
initConference ()
{
var
conference=
new
Apiomat.Conference();
var
i18n_name = {
"de"
:
"Wie benutze ich properties"
,
"en"
:
"Talk about properties"
}
conference.setI18n_name(i18n_name);
var
i18ns_guests = {
"de"
:
"Gastsprecher: John Doe"
,
"en"
:
"Guest speaker: John Doe"
}
conference.setI18n_guests(i18ns_guests);
var
saveCB = {
onOk:
function
() {
showConference(conference);
},
onError:
function
(error) {
console.log(
"error "
+error);
}
}
conference.save(saveCB);
}
* link only available in Enterprise Documentation