Handling ISO variants or get an ISO value from a multilingual text
The setLanguageVariant routine allows you to add, update, or remove ISO variants in a multilingual text value, while the getLanguageVariant routine allows you to get the value of an ISO variant from a multilingual text value.
To better illustrate how to use the setLanguageVariant and getLanguageVariant routines, this section describes some routine examples with different parameter settings. Note that the examples are not exhaustive.
The following table lists the examples which set different parameters for the routines and explains what the result will be.
Example | Description |
---|---|
setLanguageVariant("FR","Bonjour","Hello") | The setLanguageVariant routine may contain three
parameters. In this case, the first parameter indicates an ISO variant,
and the second parameter indicates its value. The last parameter shows
the original multilingual text or the value of the default ISO variant.
Note that the default ISO variant is
"EN". If the ISO variant does not appear in the original multilingual text, the ISO variant and its value will be added to the text. Otherwise, the old value of the ISO variant will be updated with the new one, without modifying the other ISO variants. After this routine example is called, the output message will be [EN:Hello][FR:Bonjour]. |
setLanguageVariant("EN","Hello world!","[EN:Hello][FR:Bonjour]") | Because the ISO variant EN already appears in the original
multilingual text, its old value "Hello" will
be updated with the new value "Hello
world!". After this routine example is called, the output message will be [EN:Hello world!][FR:Bonjour]. |
setLanguageVariant("EN","","[EN:Hello][FR:Bonjour]") | If you leave second parameter empty, the ISO variant will be
removed. After this routine example is called, the output message will be [FR:Bonjour]. |
setLanguageVariant("FR","Bonjour","Hello","EN", true) | The setLanguageVariant routine may contain five
parameters. In this case, the first parameter indicates an ISO variant,
and the second parameter indicates its value. The third parameter
indicates the original multilingual text or the value of the default ISO
variant. The fourth parameter is the default ISO variant. The last
parameter indicates whether the message will be sorted and output in
alphabetical order. If the ISO variant does not appear in the original multilingual text, the ISO variant and its value will be added to the text. Otherwise, the old value of the ISO variant will be updated with the new one, without modifying the other ISO variants. After this routine example is called, the output message will be [EN:Hello][FR:Bonjour]. |
setLanguageVariant("FR", "Ceci est mon premier produit","[EN:This is my first product][FR:Bonjour]","EN", false) | Because the ISO variant "FR" already appears in
the multilingual text, the old value
"Bonjour" will be replaced with the new
value "Ceci est mon premier produit".
Besides, the sort option is set to false, so the
message will not be sorted. After this routine example is called, the output message will be [EN:This is my first product][FR:Ceci est mon premier produit]. |
setLanguageVariant("DE","Hallo","[EN:Hello][FR:Bonjour]","EN",true) | Because the ISO variant "DE" does not appear in
the multilingual text, the variant and its value will be added. Besides,
the sort option is set to true, so the message will be
sorted and output in alphabetical order. After this routine example is called, the output message will be [DE:Hallo][EN:Hello][FR:Bonjour]. |
getLanguageVariant("EN","[EN:Hello world!][FR:Bonjour]") | The getLanguageVariant routine may contain two
parameters. In this case, the first parameter indicates the ISO variant
whose value will be fetched. The second parameter shows the multilingual
text. If the specified ISO variant does not appear in the multilingual text, the null value will be returned. The return value for this routine example is Hello world!. |
getLanguageVariant("DE","[EN:Hello][FR:Bonjour]") | Because the ISO variant "DE" does not appear in the multilingual text, the return value for this routine example is null. |
getLanguageVariant("DE","EN","[EN:Hello][FR:Bonjour]") | The getLanguageVariant routine may contain three
parameters. In this case, the first parameter indicates the ISO variant
whose value will be fetched. The second parameter indicates the default
ISO variant. The last parameter shows the multilingual text. If the specified ISO variant does not appear in the multilingual text, the value of the default ISO variant will be returned. The return value for this routine example is Hello. |