Constructors
Constructors are used to create new instances of a struct. They are used to initialize the struct with the required data.
There are 3 constructors in the GM-I18n API:
I18nLocaleInit
The I18nLocaleInit
constructor is used to create a new locale data.
Syntax
Usage
new I18nLocaleInit(lang_code, lang_name, [lang_file]);
Parameters
Name | Type | Default | Description |
---|---|---|---|
lang_code | String | The locale code, for example en or id . | |
lang_name | String | The locale name, for example English or Indonesian . | |
lang_file | String | String[] | "" | The locale file path, for example ~/langs/en.json . You can also pass an array of string if you want to load multiple files for a single locale. |
Returns
I18nLocaleInit
Examples
Create Event
// initialize the GM-I18n system
global.i18n = i18n_create("global.i18n", "en", [
new I18nLocaleInit("en", "English", "~/langs/en.json"),
new I18nLocaleInit("id", "Indonesian", "~/langs/id.json")
]);
// initialize the GM-I18n system with multiple files for a single locale
global.i18n = i18n_create("global.i18n", "en", [
new I18nLocaleInit("en", "English", ["~/langs/en1.json", "~/langs/en2.json"]),
new I18nLocaleInit("id", "Indonesian", "~/langs/id.json")
]);
You can use "
~/
" as a shorthand of working_directory
in the lang_file
parameter. But if you're targeting on HTML5 export, please don't use this shorthand.I18nLoad
Internal The I18nLoad
constructor is used to create a new locale files loader.
Syntax
Usage
new I18nLoad(interval, [i18n]);
Parameters
Name | Type | Default | Description |
---|---|---|---|
interval | Real | The interval between each locale file loading in seconds. | |
i18n | Boolean | I18n | false | The i18n struct reference, or leave it empty to use the global i18n struct. |
Returns
I18nLoad
This constructor is used internally by the
i18n_create()
function. You don't need to use it directly.I18nDrawings
The I18nDrawings
constructor is used to create a new drawing preset.
Syntax
Usage
new I18nDrawings([draw_font], [draw_halign], [draw_valign], [draw_color], [draw_scale], [draw_rotation], [draw_alpha], [text_sep], [text_width]);
Parameters
Name | Type | Default | Description |
---|---|---|---|
draw_font | Font Asset | undefined | The font to use in draw_set_font() function. |
draw_halign | HAlign | undefined | The horizontal alignment to use in draw_set_halign() function. |
draw_valign | VAlign | undefined | The vertical alignment to use in draw_set_valign() function. |
draw_color | Color | Color[] | undefined | The color to use in draw_set_color() function, or the color gradient to use in draw_text*_color() function. |
draw_scale | Real | undefined | The both scale (x_scale and y_scale ) of the text. |
draw_rotation | Real | undefined | The angle (rotation ) of the text. |
draw_alpha | Real | undefined | The opacity (alpha ) of the text. |
text_sep | Real | -1 | The distance between each line (sep ) of the text. |
text_width | Real | room_width | The maximum width (w ) of the text. |
Returns
I18nDrawings
Examples
Raw
// only for explanation purpose, DON'T copy-paste this code
// title
I18nDrawings(fnNotoSans, fa_center, fa_middle, #FFFFFF, 1.2, 0, 1);
// header
I18nDrawings(fnNotoSans, fa_left, fa_middle, #FFFFFF, 1, 0, 1);
// body
I18nDrawings(fnNotoSans, fa_left, fa_top, #CCCCCC, 0.8, 0, 1, 32, 700);
// with other font
I18nDrawings(fnRoboto, fa_right, fa_bottom, #999999, 0.7, 0, 1, -1, 700);
// font asset created from code
I18nDrawings(global.font_ja, fa_left, fa_middle, #FFFFFF, 1, 0, 1);
You can skip any parameters you don't want to use. The missing parameters will be ignored when used in
You can read the detailed explanation in the Drawing section.
i18n_use_drawing()
function. You can read the detailed explanation in the Drawing section.
These constructors only be used in the GM-I18n initialization process. So, you likely won't need to use them again after the initialization.
Table of Contents