i18n_update_plurals()
The i18n_update_plurals()
function is used to update the plural value and the used plural form in the message reference created by using the i18n_create_ref_message()
function.
This function can only be used after the i18n_create()
function is called.
Syntax
Usage
i18n_update_plurals(var_name, value, [update_refs], [i18n]);
Parameters
Name | Type | Default | Description |
---|---|---|---|
var_name | String | The name of the variable that store the message reference created by i18n_create_ref_message() function (e.g. global.my_obj.my_msg , my_obj.my_msg , my_arr.0 , my_struct.my_msg , etc.). | |
value | Real | The new plural value (e.g. 0 , 10 , 213 , etc.). | |
update_refs | Boolean | false | Update all references (message and asset) to the new plural value and the used plural form. |
i18n | Boolean | I18n | false | The i18n struct reference, or leave it empty to use the global i18n struct. |
Returns
Void
Examples
Create Event
// assume the system is initialized on global variable, and the locale is "en"
apple_count = 0;
// create a message references with pluralization
ref_msg = i18n_create_ref_message("ref_msg", "shop.has_apple", {
plural: function(plural_value) {
switch (i18n_get_locale()) {
case "en":
return (plural_value <= 0 ? 0 : (plural_value == 1 ? 1 : 2));
case "id":
return (plural_value <= 0 ? 0 : 1);
}
},
plural_value: 0
});
For the detailed example of this function, you can see the Pluralization section.
You need to use named data for pluralization, with
plural
(for the pluralization rule) and plural_value
(for the value to be passed to the pluralization rule) key. You can't use the indexed data for pluralization. See the Interpolation section for more information.Table of Contents