Customizing

You can customize the GM-I18n system to fit your needs. In this section, we will discuss about the available customization options.


Default Message

The default message is used when the message key is not found in the current locale and the fallback locale. You can set the default message when initializing the GM-I18n system using i18n_create() function, or using i18n_set_default_message() function.

Create Event
// using i18n_create()
global.i18n = i18n_create("global.i18n", "en", [
    new I18nLocaleInit("en", "English", "~/langs/en.json"),
    new I18nLocaleInit("id", "Indonesian", "~/langs/id.json")
], {
    default_message: "Missing Translation"          // default message for message fallback (default = empty string)
});

// using i18n_set_default_message()
i18n_set_default_message("Missing Translation");
The i18n_set_default_message() function can be used to change the default message after the system is initialized.

Pluralization

You can customize the pluralization index and delimiter when initializing the GM-I18n system using i18n_create() function.

Starting Index

The starting index is the index of the first plural form in the message. By default, the starting index is 0. You can change it by setting the plural_start_at key in the i18n_create() function.

Create Event
// using i18n_create()
global.i18n = i18n_create("global.i18n", "en", [
    new I18nLocaleInit("en", "English", "~/langs/en.json"),
    new I18nLocaleInit("id", "Indonesian", "~/langs/id.json")
], {
    plural_start_at: 1           // the first plural form is at index 1 (default = 0)
});

Delimiter

You can change the delimiter (default: |) by setting the plural_delimiter key in the i18n_create() function.

Create Event
// using i18n_create()
global.i18n = i18n_create("global.i18n", "en", [
    new I18nLocaleInit("en", "English", "~/langs/en.json"),
    new I18nLocaleInit("id", "Indonesian", "~/langs/id.json")
], {
    plural_delimiter: "||"       // the delimiter is now "||" (default = "|")
});
Please be aware that if you change the pluralization starting index, it will affect the pluralization rule you set in the message or reference.

For example, if you change the starting index to 1, and you have a pluralization rule in your message or reference that return 1, it will actually access the first plural form (index 0), not the second one (index 1). Because you change the starting index to 1, the first plural form is now at index 1, and the second one is at index 2.

Linked Message

You can customize the linked message placeholder when initializing the GM-I18n system using i18n_create() function by setting linked_start and linked_end key in the option parameter.

Opening and Closing Character

Create Event
// using i18n_create()
global.i18n = i18n_create("global.i18n", "en", [
    new I18nLocaleInit("en", "English", "~/langs/en.json"),
    new I18nLocaleInit("id", "Indonesian", "~/langs/id.json")
], {
    linked_start: "<",          // the opening character is now "<<" (default = "[")
    linked_end: ">"             // the closing character is now ">>" (default = "]")
});
As you can see, you only need to set the opening and closing character to 1 character. The system will automatically double the character when checking the linked message.
You can only use 1 character as the opening and closing character. You can't use multiple characters, such as << and >>. If you do so, the linked message won't be recognized.

You can't use the same character for the opening and closing character. For example, you can't use < as the opening and closing character. If you do so, the linked message won't be recognized.

Please be aware that if you change the opening and closing character, it will affect the linked message you have in your message or reference.

For example, if you change the opening character to << and the closing character to >>, and you have a linked message in your message or reference that use the default opening and closing character ([[key1]]), it will not be recognized as a linked message. You need to change it to the new opening and closing character (<<key1>>).

  Change these customization options to fit your needs!