i18n_create_cache()
The i18n_create_cache()
function is used to create a new cache in the GM-I18n system. This function is automatically called when you use the i18n_get_messages()
, i18n_create_ref_message()
, and i18n_draw_message()
functions, so you don't need to call this function manually.
This function can only be used after the i18n_create()
function is called.
Syntax
Usage
i18n_create_cache(key, [data], [locale], [value], [i18n]);
Parameters
Name | Type | Default | Description |
---|---|---|---|
key | String | The message key to create the cache for (e.g. "hello" , "bye" , "long_text" , etc.). | |
data | Integer | Any[] | Struct | undefined | The data to pass to the message. You can pass an integer for pluralization, an array for indexed data interpolation, or a struct for named data interpolation (e.g. 1 , ["Hello", "World"] , { name: "John" } ). |
locale | String | "" | The locale code to create the cache for (e.g. "en" , "id" , "ja" , etc.). Leave it empty to create the cache for the current locale. |
value | String | "" | The value to store in the cache. Leave it empty to get the message from based on the key and data parameters. |
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
// create a cache for "hello" key, from "en" locale
i18n_create_cache("hello", , "en");
// create a cache for "bye" key, from current locale
i18n_create_cache("bye");
// create a cache for "greet" key, from current locale
// using named data interpolation
i18n_create_cache("greet", {
name: "John" // {name} = "John"
});
The message caching isn't available for HTML5 export. So, this function will do nothing in HTML5.
Table of Contents