System Flow
Before you're using the GM-I18n API, you need to know how things work in the GM-I18n system. You can skip this section if you already know how things works in GM-I18n system.
Locale Files Loading
The locale file (if you're using it) will be automatically loaded when you're using the i18n_create()
function. The loading process is done asynchronously, so the messages
in the file won't be loaded immediately. Therefore, you need to wait until the loading is finished before you can use the GM-I18n API.
Here's how the locale files loading works:
- You initialize the GM-I18n system using
i18n_create()
function and update the system usingi18n_update_loader()
function. - The system check if you're trying to import any locale file using
i18n_create()
function. - Your game run by 1 step:
- If the
time
option was set in the GM-I18n system initialization, add current step to the system.- If the step passed the
time
interval, the system load your unloaded locale file sequentially. - If all locale files haven't loaded completely, repeat step 3 until all locale files are loaded to the system.
- If all locale files have been loaded completely, continue to the step 4.
- If the step passed the
- If the
time
option wasn't set in the GM-I18n system initialization, those files will be loaded immediately. Continue to the step 4.
- If the
- The system remove the
loader
after all locale files have been loaded.

Wrong way (not recommended):
// 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")
]);
// get the message from "en" locale
msg = i18n_get_messages("en", "hello");
// print the message
show_debug_message(msg);
// this will print an empty string (""), because the locale files aren't loaded immediately after the system is initialized. it will load the locale files after 1 step of the game.
// almost all of i18n_* functions that you use before the locale files are loaded won't work properly, whether it's on the objI18n object or other object.
Right way (recommended):
// 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")
]);
// hardcode the mandatory messages
i18n_add_messages("en", "hello", "Hello World!");
// get the message from "en" locale
msg = i18n_get_messages("en", "hello");
// print the message
show_debug_message(msg);
message
to the system: importing the locale file through i18n_create()
function, or add it manually using i18n_add_messages()
function after the system is initialized. If you aren't setting the
time
option when initializing the GM-I18n system, the system will load all locale files after 1 step of the game. You're recommended to hardcode the mandatory messages (such as the UI text) so you can use it immediately after the system is initialized.
Use
i18n_is_ready()
to check whether the GM-I18n is ready (all locale files have been loaded) or not.Drawing Presets
In a nutshell, the drawing presets are just a wrapper for the draw_set_*
functions. It's optional to use the drawing presets, but it's recommended to use it if you want to draw the translated text consistently.
/*
* i18n_create() code
*/
i18n_add_drawings(["en", "id"], ["header", "body"], [
new I18nDrawings(fnNotoSans, fa_left, fa_middle, #FFFFFF, 1, 0, 1), // header
new I18nDrawings(fnNotoSans, fa_left, fa_top, #CCCCCC, 0.8, 0, 1, -1, 700) // body
]);
draw_set_*
if you don't use the drawing presets, or using the drawing presets in inefficient way. For example, you use draw_set_font()
before calling i18n_use_drawing()
, or you use draw_set_halign()
after calling i18n_use_drawing()
. The GM-I18n system is not fault-tolerant for this case. It's recommended to use the drawing templates to avoid any unexpected behavior. You can see the detailed explanation in the Optimizations section.