[{"data":1,"prerenderedAt":515},["ShallowReactive",2],{"search-api":3},[4,11,23,33,42,54,63,74,84,95,104,112,120,129,139,148,157,165,175,185,195,207,214,221,228,235,242,249,256,263,270,277,284,291,298,305,312,319,326,333,340,347,354,361,368,375,382,389,396,403,410,417,424,431,438,445,452,459,466,473,480,487,494,501,508],{"id":5,"path":6,"dir":7,"title":8,"description":7,"keywords":9,"body":10},"content:0.index.md","/","","Home",[],"     Unlock your potential players' hearts with their favorite language   Empower your game with   localized content  and   multilingual support  to reach your audience in multiple languages. Don't waste your time on the manual language-translation work, let   GM-I18n  handle the localization for you.     Lightweight and performance-oriented library  Comprehensive multi-language support with   JSON -based locale files  Automatic locale file loading with configurable timing  Flexible and ease of use   translation  system  Advanced   pluralization  with customizable rules   Dictionary  system to make your translation more   natural   On-the-fly  language switching without restarting the game    Quick start:\n1. Download the latest release\n2. Import it to your project\n3. Use the GM-I18n system\n        What's included      Fast and Powerful Translation   Translate your game content in seconds after setting up the GM-I18n system.    Direct Drawing Support   Create your own drawing presets and use them to draw the translated text consistently.    Localized Assets   Not only text translation, but also sprites, sounds, and other assets can be localized.    Strong-typed Parameters   Reduce the risk of typos and errors with strong-typed parameters while using the   GM-I18n  system.    Fault-tolerant System   Your game won't crash when you make a mistake while using the   GM-I18n  system.    Robust Fallback System   Unavailable translations or assets will be handled automatically to your default language.    Built-in Debug Messages   Debug messages will be printed in the console, whether as successes, warnings, or errors.    Performance-oriented Library   The   GM-I18n  system aim to be as fast as possible without sacrificing performance and readability.    Extensible   Customize the source code with your own logic, or mix it with other libraries to create a more complete solution.",{"id":12,"path":13,"dir":14,"title":15,"description":7,"keywords":16,"body":22},"content:v1:1.getting-started:1.introduction.md","/v1/getting-started/introduction","getting-started","Introduction",[17,18,19,20,21],"Questions & Feature Requests","Changelog","Contributing","Support","License","  Introduction     GM-I18n  is a simple and powerful internationalization library for GameMaker 2.3+. It primarily focuses on providing a simple and easy-to-use API for easy localization of your game and its content. Don't forget to leave a star on the   GitHub repository ! ⭐  I'm trying my best to maintain and improve this library as professional as possible, though it's not intended to be a full-fledged localization solution (like   Vue I18n  or   React i18next , which is designed for web applications).  This library is designed to be as fault-tolerant as possible, but it's still a best practice to   back up  your game files before using the GM-I18n system. It's also a good idea to use a   version control system  (like Git or GitHub) to manage your game files.   Questions & Feature Requests  Feel free to start a   discussion  if you have any questions or suggestions. Also feel free to open an   issue  if you want to report a bug or request a feature.  I'll try my best to answer your questions and implement your feature requests. But, please don't expect too much, I'm not that professional and I'm doing this in my free time.   Changelog  See the   changelog  for more information about the changes in each version.   Contributing  How to contribute to this project:   Fork the   GM-I18n repository .  Clone the forked repository to your local machine.  Make and test your changes.  Commit your changes and push it to your forked repository.  Open a pull request to the main repository.  Please make sure to follow the code style of the project.  For major changes, please open an issue first to discuss what you would like to change.   Support  If you like this project, please consider supporting me on   Ko-fi  or   Trakteer . Your support is greatly appreciated!   License  GM-I18n is   free  and   open-source , and it's distributed under the   MIT License . ",{"id":24,"path":25,"dir":14,"title":26,"description":27,"keywords":28,"body":32},"content:v1:1.getting-started:2.limitation.md","/v1/getting-started/limitation","Issues & Limitations","As I mentioned before, GM-I18n is still in very early stages of development, so you should be aware of the following issues before using it in your game.",[29,30,31],"Limited Support for HTML5 Export","No Built-in Text Analysis Function","No Support for Complex Scripts","  Issues & Limitations  As I mentioned before,   GM-I18n  is still in very early stages of development, so you should be aware of the following issues before using it in your game.   Limited Support for HTML5 Export   GM-I18n  is not fully compatible with HTML5 export yet. There's an issue with the non-Latin fonts. I'm already working on it, but I still don't know how to solve it. If you have any idea or suggestion, please feel free to open an issue or start a discussion on the   GitHub repository .   There's   no  issue with text drawing if you're using Latin-based fonts. But, for non-Latin fonts, here's the issue that I found so far:   The text is not drawn correctly. As you can see in the image above, the text is only drawn on the button.  Even if it's drawn correctly, the text is not drawn in the correct configuration like in the drawing preset. For example, the font size, color, and alignment is not applied correctly.  Here's what I tried so far:   I tried to use the   draw_set_font  built-in function instead of   i18n_use_drawing  or   i18n_draw_message  function, it doesn't work.  I tried drawing the text manually using   draw_text  function (and its derivatives), it doesn't work. It also the same if I use the   draw_set_font  function.  I change the   Draw Event  to   Draw GUI Event . The text is drawn, but it's not drawn in the correct configuration like in the drawing preset.  I tried to toggle the WebGL option in the HTML5 export settings. It doesn't work.  I'm completely stuck, so there's no temporary solution for this issue. If you have any idea or suggestion, please feel free to open an issue or start a discussion on the   GitHub repository .   You can see the issue in action in the demo project (HTML5) and in the   GitHub pages .   No Built-in Text Analysis Function   GM-I18n  doesn't have any built-in text analysis function yet. So, if your translation is a \"one word message\", it will be drawn as a single line even if you set the width in the drawing preset.   Temporary solution:  you have to add a space (    ) or a newline character (  \\n ) manually in the translation string.      {\n       \"text\"  :   \"この文は静的です。選択されたロケールに翻訳されます。ロケールを変更してもこの文には影響しません。\"\n   }\n     {\n       \"text\"  :   \"この文は静的です。選択された ロケールに翻訳されます。ロケールを 変更してもこの文には影響しません。\"\n   }\n  I've actually implemented a   force_wrap  parameter in the    I18nDrawings  constructor back then, but it was causing performance issue. Since   GM-I18n  is a performance-oriented library, I decided remove it for now. Stay tuned for future updates!   This issue is happening in any platform.   No Support for Complex Scripts  I've tested   GM-I18n  with some languages that has a complex script, like   Arabic , and the text is not drawn correctly (no cursive connection between the characters). I haven't tested it with other complex script (such as   Thai ,   Tamil ,   Devanagari , etc.) yet, but it's likely to have the same issue.  I had thought about implementing the RTL feature, but I decided to hold off for now (because languages that use RTL also use complex scripts). If you need it, feel free to open an issue or start a discussion on the   GitHub repository .        If you're ready to accept the issues above, then you're ready to use   GM-I18n  in your game!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":34,"path":35,"dir":14,"title":36,"description":7,"keywords":37,"body":41},"content:v1:1.getting-started:3.setup.md","/v1/getting-started/setup","Setup",[38,39,40],"Requirements","Installation","Configuration","  Setup  Requirements  Here's a list of the tested versions of GameMaker that works properly with   GM-I18n .     Platform  IDE  Runtime  Notes    Windows VM  v2024.13.1.193  v2024.13.1.242  All API works properly   Windows YYC  v2024.13.1.193  v2024.13.1.242  All API works properly   HTML5  v2024.13.1.193  v2024.13.1.242  Core API works properly, but there's an issue with the drawing functions  It should work on other versions of GameMaker 2.3+ too. Please let me know on the   tested versions page  if you tested it on other versions that not listed above, whether it works properly or not. It will help me and other users who want to know which versions of GameMaker that works properly with   GM-I18n .   Installation  Importing/Upgrading Package  There're 2 ways to import/upgrade the   GM-I18n  package to your project. You can choose one that you prefer.  Using Package Manager   Download the latest release from the   releases page .       Import the   GM-I18n v\u003Cversion>.yymps  file to your project by dragging it to the IDE.       Select the   scI18n  script from the list to import and click   Add , or just click   Add All . And finally, click the   Import  button.       If you're upgrading the package, a new window will appear. Checklist the   Replace  option and then click the   Import  button.       Manual Import   Download the latest release from the   releases page .       Extract the downloaded file. You should see 5 files:   GM-I18n v\u003Cversion>.yymps ,   I18nConstants.d.ts ,   I18nConstructors.d.ts ,   I18nFunctions.d.ts , and   scI18n.gml .       Open the   scI18n.gml  file and then copy the content of it to a new script in your project.  Offline Documentation (Optional)  There's some types definition files in the package, which is   I18nConstants.d.ts ,   I18nConstructors.d.ts , and   I18nFunctions.d.ts . These files are types definition files that you can use to help you understand better how to use the   GM-I18n  API.  Think of it as a cheatsheet for   GM-I18n  documentation. It's not as comprehensive as the web documentation, but it's better than nothing. If you want to use it, you can follow the steps below:   Extract the downloaded file. You should see 5 files:   GM-I18n v\u003Cversion>.yymps ,   I18nConstants.d.ts ,   I18nConstructors.d.ts ,   I18nFunctions.d.ts , and   scI18n.gml .       Open the   GM-I18n v\u003Cversion>  folder with your favorite code editor (such as   Visual Studio Code ,   Lite XL ,   Atom , or other code editor you prefer).       You're done! You can use it as a \"side-by-side\" reference for the   GM-I18n  API.       If you're using   Visual Studio Code  (or other advanced code editor) as your secondary code editor for this purpose, you may get a better experience than using the GameMaker's built-in code editor. You can get the hover tooltip, type hints, jump-to-definition, and other features that make your coding experience better.    Configuration  You can create your own   fonts  asset normally if the language you're using is a Latin-based language. But, if you're adding language with non-Latin characters, you   need  to follow the steps below:  Using Font Assets   Create a new   font  asset in the IDE as you usually do.  Click   Add  to add new range to the font asset for each character range you need. Set the   from  and   to  to the first and last character of the range. For example, if you're adding Japanese, you may add   Higarana  (  12352  to   12447 ),   Katakana  (  12448  to   12543 ), and   Kanji  (  13312  to   19903 ).       Click   Add Range  after you done adding all the ranges you need.  Repeat the steps above for each font you need.   You can find the character ranges for other languages   here . Please note that the ranges are in decimal format, while the website shows it in hexadecimal. You can use an online converter to convert the hexadecimal to decimal.   Please also note that   using too many ranges may cause the font asset to be too large, may cause performance issues, and may the characters won't be displayed correctly . So, try to use as few ranges as possible.  Using Included Files   Prepare your font files. You can use any font you want, but make sure it's in   .ttf  or   .otf  format. You can convert any font to   .ttf  or   .otf  format using online converters.  Click   Menu  button in the Asset Browser (that one with 3 stripes icon), and then click   Included Files . The   Included Files  window will open, and then click   Open in Explorer .       A window will open and show you the   datafiles  folder of your project. Copy your font files there (with its license file). You can also make a folder for your font files, for example   fonts .       In the   Included Files  window, click   Refresh  button. Your font files should now appear in the list.  Create the font asset from code. Use the    font_add()  function to create the font asset. For example:     // font_add(name, size, bold, italic, first, last);\n   global.font_ja   =   font_add  (working_directory   +   \"fonts/NotoSansJP-Medium.ttf\"  ,   32  ,   false  ,   false  ,   32  ,   127  );\n   If you're targetting to HTML5 export, don't use   working_directory  before the file path.   Repeat step 5 for each font you need.   It's recommended to set it to a global variable (and delete it with    font_delete()  if you don't need it anymore). Pass the   32  to the   first  parameter, and   128  to the   last  parameter if you're not sure.   Please take note that   using this method will load all glyphs in the font , so   there is risk of a memory leak which will slow down and eventually crash your game .        That's it, you're almost done to use the GM-I18n system!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":43,"path":44,"dir":45,"title":46,"description":47,"keywords":48,"body":53},"content:v1:2.core-concepts:1.i18n-system.md","/v1/core-concepts/i18n-system","core-concepts","I18n System","Let's initialize a simple GM-I18n system to translate the text in the game. We will use the en and id locale, and translate the \"Hello World\" text.",[49,50,51,52],"Import Locale Files","Initialize the System","Create Font Assets","Create Drawing Presets","  I18n System  Let's initialize a simple GM-I18n system to translate the text in the game. We will use the   en  and   id  locale, and translate the \"Hello World\" text.   Import Locale Files   Prepare your locale files. Currently, GM-I18n only support   JSON  file as the locale file. Create a JSON file that contains the translation data. The file structure is as follows:      {\n       \"hello\"  :   \"Hello World!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"\n   }\n   The file name can be anything, but for clarity, we will use the locale code as the file name, for example   en.json  and   id.json .  The locale files are optional. You can add the text translation later with the    i18n_add_messages()  function.   Click   Menu  button in the Asset Browser (that one with 3 stripes icon), and then click   Included Files . The   Included Files  window will open, and then click   Open in Explorer .       A window will open and show you the   datafiles  folder of your project. Copy your locale files there. You can also make a folder for your locale files, for example   langs .       In the   Included Files  window, click   Refresh  button. Your locale files should now appear in the list.   Initialize the System   Create a new object, for example   objI18n . It's recommended to mark it as   Persistent  object.  Create the I18n system in   objI18n :    Using   global  variable       // i18n_create(var_name, default_locale, locales)\n   // I18nLocaleInit(lang_code, lang_name, [lang_file])\n   \n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ]);\n     // update the i18n system\n   i18n_update_loader  ();\n    Using   instance  variable       // i18n_create(var_name, default_locale, locales)\n   // I18nLocaleInit(lang_code, lang_name, [lang_file])\n   \n   i18n   =   i18n_create  (  \"i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ]);\n     // update the i18n system\n   i18n_update_loader  ();\n   It's highly recommended to use   global  variable to store the I18n system, but you can use it on   objI18n  instance variable instead. If you're using instance variable, you need to pass the    I18n  struct created by the    i18n_create()  function.       The   var_name  is the actual variable name. It need to match with the variable name that you use to store the I18n system. We're using   i18n  global variable, so the   var_name  is   global.i18n . If it's declared on instance variable, you can remove the   global  keyword.       You can use standard locale code (such as   en_US ), but don't use stripe (  - ) for the separator. You can also add   \"~/\"  to the file path as a shorthand of    working_directory . But if you're targeting on HTML5 export, please don't use this shorthand.       The    i18n_update_loader()  function is used to update the loading progress of the locale files. Only use this function if you're importing the text translation through JSON files.       The    i18n_create()  function used in the code above is a really basic initialization. You can find the full documentation of the    i18n_create()  function.   Create Font Assets  If you haven't created the font assets for each language you're using, you need to create it first. Let's assume we've created the font assets through IDE called   fnNotoSans . Because both locale we're using is Latin-based, we can use the same font asset for both locale.   You can skip this step if you're only using Latin-based languages.       You can find the detailed instruction in the   Configuration  section.   Create Drawing Presets  It's optional, but it's recommended to create a drawing preset for each locale. Let's create a simple   header  and   body  drawing presets!    Using   global  variable      /*\n    * i18n_create() code\n   */\n   \n   // i18n_add_drawings(locale, preset_name, data, [use_ref], [i18n])\n   // I18nDrawings([draw_font], [draw_halign], [draw_valign], [draw_color], [draw_scale], [draw_rotation], [draw_alpha], [text_sep], [text_width], [is_template])\n   \n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ], [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),               // header\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )        // body\n   ]);\n    Using   instance  variable      /*\n    * i18n_create() code\n    */\n   \n   // i18n_add_drawings(locale, preset_name, data, [use_ref], [i18n])\n   // I18nDrawings([draw_font], [draw_halign], [draw_valign], [draw_color], [draw_scale], [draw_rotation], [draw_alpha], [text_sep], [text_width], [is_template])\n   \n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ], [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),               // header\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )        // body\n   ],   true  , i18n);                                                                       // pass the i18n struct\n   You can skip this step if you don't want to use the drawing preset feature.       You can find the detailed instruction in the   Drawing  section.       As you can see, you need to pass the    I18n  struct everytime you're using any   i18n_*  functions. What a hassle, right? That's why I recommend to create the   i18n  system in the   global  variable.        Congrats, you're ready to use the GM-I18n system!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":55,"path":56,"dir":45,"title":57,"description":58,"keywords":59,"body":62},"content:v1:2.core-concepts:2.system-flow.md","/v1/core-concepts/system-flow","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.",[60,61],"Locale Files Loading","Drawing Presets","  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 using    i18n_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:\n   If the   time  option was set in the   GM-I18n  system initialization, add current step to the system.\n   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   time  option wasn't set in the   GM-I18n  system initialization, those files will be loaded immediately. Continue to the step 4.  The system remove the   loader  after all locale files have been loaded.    Wrong way (not recommended):      // initialize the GM-I18n system\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ]);\n   \n   // get the message from \"en\" locale\n   msg   =   i18n_get_messages  (  \"en\"  ,   \"hello\"  );\n   \n   // print the message\n   show_debug_message  (msg);    \n   \n   // 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.\n   // 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.\n     // update the GM-I18n system, need certain time to load the locale files\n   // the `time` is not set in the i18n_create() function, so it will load the locale files immediately after 1 step of this object\n   i18n_update_loader  ();\n     // draw a dynamic message. it will draw an empty text until the locale files are loaded (that contain the \"hello\" key message)\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  , ,   \"header\"  );\n   Right way (recommended):      // initialize the GM-I18n system\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ]);\n   \n   // hardcode the mandatory messages\n   i18n_add_messages  (  \"en\"  ,   \"hello\"  ,   \"Hello World!\"  );\n   \n   // get the message from \"en\" locale\n   msg   =   i18n_get_messages  (  \"en\"  ,   \"hello\"  );\n   \n   // print the message\n   show_debug_message  (msg);\n     // update the GM-I18n system, need certain time to load the locale files\n   // the `time` is not set in the i18n_create() function, so it will load the locale files immediately after 1 step of this object\n   i18n_update_loader  ();\n     // draw a dynamic message. it only will draw the message after the locale files are loaded\n   // the i18n_is_ready() function is optional \n   if   (  i18n_is_ready  ()) {\n       i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  , ,   \"header\"  );\n   }\n   There are two ways to add a   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.      /*\n    * i18n_create() code\n   */\n   \n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ], [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),               // header\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )        // body\n   ]);\n     // use the dynamic drawing preset\n   i18n_use_drawing  (  \"header\"  );\n   \n   /* \n    * the i18n_use_drawing(\"header\") is the same as:\n    * draw_set_font(fnNotoSans);\n    * draw_set_halign(fa_left);\n    * draw_set_valign(fa_middle);\n    * draw_set_color(#FFFFFF);\n    * draw_set_alpha(1);\n   */\n   \n   // and then draw the message\n   draw_text  (  100  ,   50  ,   \"Hello, GM-I18n User!\"  );           // static text, the drawing preset still applied\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  );\n   \n   // you can also use a shorthand (using the drawing preset directly to the i18n_draw_message())\n   // i18n_draw_message(100, 50, \"@:hello\", , \"header\");\n   You can find the detailed instruction in the   Drawing  section.   You may call unecessary   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.        Have you gotten an overview of the   GM-I18n  system? Just ask me if you have any questions!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":64,"path":65,"dir":45,"title":66,"description":67,"keywords":68,"body":73},"content:v1:2.core-concepts:3.fallback.md","/v1/core-concepts/fallback","Fallback","Fallback is a mechanism that allows you to provide default value (translations for messages, or localized assets) that are not available in the current locale.",[69,70,71,72],"Initialization","How It Works?","Message Fallback","Localized Asset Fallback","  Fallback  Fallback is a mechanism that allows you to provide default value (translations for messages, or localized assets) that are not available in the current locale.  This ensures that your game can still display meaningful content even when specific translations or assets are missing.   You're recommended to set the fallback locale to the   most complete  locale you have. For example, if you have 3 locales (  en ,   id , and   ja ), and the   en  locale has the most complete translation, you should set the fallback locale to   en .   Initialization  You're required to set the fallback locale when initializing the GM-I18n system using    i18n_create()  function.     // i18n_create(var_name, default_locale, locales, [options])\n   // the `default_locale` is the fallback locale\n   // so, if message keys or localized assets are not found in the current locale, \n   // it will take the value from the fallback locale\n   \n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"Japanese\"  ,   \"~/langs/ja.json\"  )\n   ]);\n  Your fallback system is now ready to use!  You can start using    i18n_get_messages() ,    i18n_create_ref_message() , and    i18n_create_ref_asset()  function to get messages and localized assets with fallback mechanism.   How It Works?   You can set the default message for message fallback in the    i18n_create()  function by passing the   default_message  in the   options  parameter.     // i18n_create(var_name, default_locale, locales, [options])\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"Japanese\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       default_message:   \"Missing Translation\"            // default message for message fallback (default = empty string)\n   });\n   The   default_message  is only used for   message  fallback. It won't affect the localized asset fallback.       You can see the available options in the   API Reference .   Message Fallback  The message fallback is triggered when the message key is not found in the current locale. It will take the message from the fallback locale instead, or the   default_message  if the message is not found in the fallback locale.  You're recommended to read the   Messages  section first before proceeding to this section.      // assume the system is initialized on global variable\n   // assume the fallback locale is \"en\" and the default message is \"Missing Translation\"\n   // i18n_get_messages(key, [data], [locale], [i18n])\n   \n   // static messages\n   msg1   =   i18n_get_messages  (  \"hello\"  , ,   \"en\"  );                // \"Hello World!\"\n   msg2   =   i18n_get_messages  (  \"bye\"  , ,   \"ja\"  );                  // \"さようなら世界！\"\n   msg3   =   i18n_get_messages  (  \"info\"  , ,   \"en\"  );                 // \"Missing Translation\", because \"info\" is not defined in \"en\" locale\n   msg4   =   i18n_get_messages  (  \"cancel\"  , ,   \"ja\"  );               // \"Missing Translation\", because \"cancel\" is not defined in \"ja\" locale, and also not defined in the fallback locale\n   \n   // dynamic messages\n   ref_msg1   =   i18n_create_ref_message  (  \"ref_msg1\"  ,   \"hello\"  );              // \"Hello World!\", \"Halo Dunia!\", or \"こんにちは世界！\"\n   ref_msg2   =   i18n_create_ref_message  (  \"ref_msg2\"  ,   \"world.stand\"  );        // \"The World!\", \"Missing Translation\", or \"ザ・ワールド！\"\n   ref_msg3   =   i18n_create_ref_message  (  \"ref_msg3\"  ,   \"info\"  );               // always \"Missing Translation\", because \"info\" is not defined in any locale\n     // change the locale\n   // i18n_set_locale(code, [update_refs], [i18n])\n   \n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :\n           i18n_set_locale  (  \"id\"  );        // ref_msg1 = \"Halo Dunia!\", ref_msg2 = \"Missing Translation\",\n           break  ;                        // ref_msg3 = \"Missing Translation\" \n   \n       case   \"id\"  :\n           i18n_set_locale  (  \"ja\"  );        // ref_msg1 = \"こんにちは世界！\", ref_msg2 = \"ザ・ワールド！\"\n           break  ;                        // ref_msg3 = \"Missing Translation\" \n   \n       case   \"ja\"  :\n           i18n_set_locale  (  \"en\"  );        // ref_msg1 = \"Hello World!\", ref_msg2 = \"The World!\", \n           break  ;                        // ref_msg3 = \"Missing Translation\" \n   }\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Bye World!\"  ,\n       \"world\"  : {\n           \"stand\"  :   \"The World!\"  ,\n           \"effect\"  :   \"Stop the Time!\"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai Jumpa Dunia!\"\n   }\n     {\n       \"hello\"  :   \"こんにちは世界！\"  ,\n       \"bye\"  :   \"さようなら世界！\"  ,\n       \"world\"  : {\n           \"stand\"  :   \"ザ・ワールド！\"  ,\n           \"effect\"  :   \"時よ止まれ！\"\n       }\n   }\n   The message interpolation, pluralization, and dictionary features are still   working  as usual even with the fallback mechanism.       The   data  you passed to the    i18n_get_messages()  function or    i18n_create_ref_message()  function is also   passed  to the message in the fallback locale (and even to the   default message  if the message is not found in the fallback locale).   Localized Asset Fallback  The localized asset fallback is triggered when the asset is not found in the current locale. It will take the asset from the fallback locale instead, or the asset in the default locale if the asset is not found in the fallback locale.  You're recommended to read the   Localized Assets  section first before proceeding to this section.      // assume the system is initialized on global variable\n   // assume the fallback locale is \"en\"\n   // i18n_create_ref_asset(var_name, locale_asset, [i18n])\n   \n   // create the asset references\n   my_spr   =   i18n_create_ref_asset  (  \"my_spr\"  , {\n       en: sprSplashEn,\n       id: sprSplashId,\n       ja: sprSplashJa\n   });\n   \n   my_info_spr   =   i18n_create_ref_asset  (  \"my_info_spr\"  , {\n       en: sprInfoEn,\n       id: sprInfoId\n   });\n   \n   my_snd   =   i18n_create_ref_asset  (  \"my_snd\"  , {\n       en: sndVoiceEn,\n       id: sndVoiceId,\n       ja: sndVoiceJa\n   });\n   \n   my_sfx   =   i18n_create_ref_asset  (  \"my_sfx\"  , {\n       id: sfxButtonId,\n       ja: sfxButtonJa\n   });\n   \n   my_obj   =   i18n_create_ref_asset  (  \"my_obj\"  , {\n       en: objPlayerEn\n   });\n     // change the locale\n   // i18n_set_locale(code, [update_refs], [i18n])\n   \n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :\n           i18n_set_locale  (  \"id\"  );        // my_spr = sprSplashId, my_info_spr = sprInfoId, my_snd = sndVoiceId, \n           break  ;                        // my_sfx = sfxButtonId, my_obj = objPlayerEn (\"id\" locale doesn't have the asset)\n   \n       case   \"id\"  :\n           i18n_set_locale  (  \"ja\"  );        // my_spr = sprSplashJa, my_info_spr = sprInfoEn (\"ja\" locale doesn't have the asset), \n           break  ;                        // my_snd = sndVoiceJa, my_sfx = sfxButtonJa, my_obj = objPlayerEn (\"ja\" locale doesn't have the asset)\n   \n       case   \"ja\"  :\n           i18n_set_locale  (  \"en\"  );        // my_spr = sprSplashEn, my_info_spr = sprInfoEn, my_snd = sndVoiceEn, \n           break  ;                        // my_sfx = sfxButtonJa (fallback locale doesn't have the asset, so it won't be changed), my_obj = objPlayerEn\n   }\n     // play the sound\n   audio_play_sound  (my_snd,   1  ,   false  );\n   audio_play_sound  (my_sfx,   1  ,   false  );\n     // draw the sprite\n   draw_sprite  (my_spr,   0  ,   100  ,   50  );\n   draw_sprite  (my_info_spr,   0  ,   100  ,   200  );\n    The    i18n_get_locale()  function will return the current locale code. You can use this function to change the locale.       Take note that the    i18n_set_locale()  function will also update all references (message and asset) by default. So, you don't need to update the references manually using    i18n_update_refs() .       It's that easy to implement the fallback mechanism in your game!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":75,"path":76,"dir":77,"title":78,"description":79,"keywords":80,"body":83},"content:v1:3.usage:1.messages.md","/v1/usage/messages","usage","Messages","A message is a translated text that you will use in GM-I18n system. It's also known as text or translation in other localization system.",[81,82],"Static Messages","Dynamic Messages","  Messages  A   message  is a translated text that you will use in GM-I18n system. It's also known as   text  or   translation  in other localization system.  Here's an example locale messages we will use in this section:      {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"  ,\n       \"button\"  : {\n           \"text\"  :   \"Click me!\"  ,\n           \"confirm\"  :   \"Are you sure?\"  ,\n           \"cancel\"  :   \"Cancel\"\n       },\n       \"menu\"  : {\n           \"file\"  :   \"File\"  ,\n           \"edit\"  :   \"Edit\"  ,\n           \"help\"  : {\n               \"about\"  :   \"About\"  ,\n               \"quit\"  :   \"Quit\"\n           }\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"  ,\n       \"button\"  : {\n           \"text\"  :   \"Klik saya!\"  ,\n           \"confirm\"  :   \"Apakah Anda yakin?\"  ,\n           \"cancel\"  :   \"Batal\"\n       },\n       \"menu\"  : {\n           \"file\"  :   \"File\"  ,\n           \"edit\"  :   \"Edit\"  ,\n           \"help\"  : {\n               \"about\"  :   \"Tentang\"  ,\n               \"quit\"  :   \"Keluar\"\n           }\n       }\n   }\n   Static Messages  You can get a static message from the GM-I18n system using the    i18n_get_messages()  function   anywhere  in your game.      // assume the system is initialized on global variable\n   // i18n_get_messages(key, [data], [locale], [i18n], [create_cache])\n   msg   =   i18n_get_messages  (  \"hello\"  , ,   \"en\"  );                      // \"Hello World!\", whether the current locale is \"en\" or not (static)\n   msg_arr   =   i18n_get_messages  ([  \"bye\"  ,   \"long_text\"  ], ,   \"id\"  );     // [\"Sampai jumpa Dunia!\", \"Lorem ipsum ...\"], static\n     // get message from other object\n   msg   =   i18n_get_messages  (  \"button.text\"  , ,   \"id\"  );               // \"Klik saya!\", static\n   \n   // set to global variable\n   global.hello_text   =   i18n_get_messages  (  \"hello\"  , ,   \"id\"  );       // \"Halo Dunia!\", static\n     // assume the current locale is \"en\"\n   msg   =   i18n_get_messages  (  \"button.text\"  );        // \"Click me!\", static\n   You   need  to pass the   locale code  you want to get the message from. If you want to get the static message from the current locale, you can leave the   locale  parameter empty.       You can also use    i18n_get_messages()  function without passing the   i18n  struct if you're creating the I18n system in the   global  variable.       You can pass an array of keys to the   key  parameter to get multiple messages at once. The function will return an array of messages.       The   data  parameter is used to interpolate the message. We will discuss this in the   Interpolation  section.   Dynamic Messages  A dynamic messages is a bit tricky for newcomer. You normally can't get the dynamic message using    i18n_get_messages()  function. You can, but it's strongly not recommended. Your game will have performance issue if you're using    i18n_get_messages()  function to get the dynamic message.  Here's how you can get the dynamic message in   wrong way :      // assume the system is initialized on global variable\n   // declare the variable\n   msg   =   \"\"  ;\n     // get the message from the current locale every step, strongly not recommended!\n   msg   =   i18n_get_messages  (  \"hello\"  );\n  How to get the dynamic message correctly?  You need to use    i18n_create_ref_message()  function to create a reference to the message, and then you can use it like a normal message.     // assume the system is initialized on global variable\n   // i18n_create_ref_message(var_name, key, [data], [i18n])\n   msg   =   i18n_create_ref_message  (  \"msg\"  ,   \"hello\"  );            // create the message reference\n  That's it! Now you can use the   msg  variable like a normal message. The   msg  variable will automatically update itself when the locale is changed by calling    i18n_set_locale()  function.  How simple, right? But here's the problem comes, what should I pass to the   var_name  parameter?  Variable Name Handling  The   var_name  parameter is actually the name of the variable that you want to store the message reference. In the example above, we're storing the message reference in the   msg  variable, so the   var_name  is   msg . Here's the detailed explanation:     // assume the system is initialized on global variable\n   \n   // the variable name is \"msg\"\n   msg   =   i18n_create_ref_message  (  \"msg\"  ,   \"hello\"  );      \n   \n   // the variable name is \"button_text\"\n   button_text   =   i18n_create_ref_message  (  \"button_text\"  ,   \"button.text\"  );\n   \n   // message ref in array, the variable name is \"my_arr\"\n   my_arr   =   [\n       i18n_create_ref_message  (  \"my_arr.0\"  ,   \"hello\"  ),         // this reference is created in index 0\n       i18n_create_ref_message  (  \"my_arr.1\"  ,   \"bye\"  ),           // this one is in index 1, separate the array index with dot \".\"\n       \"\"  ,\n       i18n_create_ref_message  (  \"my_arr.3\"  ,   \"long_text\"  )      // not always need to be created consecutively\n   ];\n   \n   // message ref in struct, the variable name is \"my_struct\"\n   my_struct   =   {\n       text :   i18n_create_ref_message  (  \"my_struct.text\"  ,   \"hello\"  ),                  // the key is \"hello\"\n       button :   i18n_create_ref_message  (  \"my_struct.button\"  ,   \"button.text\"  ),        // the var_name is this struct member name\n       about :   i18n_create_ref_message  (  \"my_struct.edit\"  ,   \"menu.help.about\"  ),       // separate the struct member with dot \".\"\n       nested : {\n           bye :   i18n_create_ref_message  (  \"my_struct.nested.bye\"  ,   \"bye\"  )            // you can nest the struct as deep as you want\n       },\n       arr : [\n           i18n_create_ref_message  (  \"my_struct.arr.0\"  ,   \"hello\"  ),                    // you can also create the reference in array\n           i18n_create_ref_message  (  \"my_struct.arr.1\"  ,   \"bye\"  )\n       ]\n   }\n   \n   // message ref in global variable, the variable name is \"global.hello_text\"\n   global.hello_text   =   i18n_create_ref_message  (  \"global.hello_text\"  ,   \"hello\"  );        // use \"global\" keyword like you're defining a global variable\n   global.button_text   =   i18n_create_ref_message  (  \"g.button_text\"  ,   \"button.text\"  );     // you can use \"g.\" shorthand for \"global.\"\n   \n   // message ref in global array\n   global.gb_arr   =   [\n       i18n_create_ref_message  (  \"g.gb_arr.0\"  ,   \"hello\"  ),           // same as you're creating the reference in instance variable,\n       i18n_create_ref_message  (  \"global.gb_arr.1\"  ,   \"bye\"  )         // but use \"global.\" or \"g.\" as the prefix\n   ];\n   \n   // message ref in global struct\n   global.gb_struct   =   {\n       text :   i18n_create_ref_message  (  \"global.gb_struct.text\"  ,   \"hello\"  ),             // same as you're creating the reference in instance variable,\n       button :   i18n_create_ref_message  (  \"g.gb_struct.button\"  ,   \"button.text\"  ),        // but use \"global.\" or \"g.\" as the prefix\n       menu : {\n           about :   i18n_create_ref_message  (  \"g.gb_struct.menu.about\"  ,   \"menu.help.about\"  )     // a nested struct in global struct\n       },\n       arr : [\n           i18n_create_ref_message  (  \"global.gb_struct.arr.0\"  ,   \"hello\"  ),              // you can also create the reference in array\n           i18n_create_ref_message  (  \"g.gb_struct.arr.1\"  ,   \"bye\"  )\n       ]\n   };\n   The    i18n_create_ref_message()  and    i18n_set_locale()  function is the core of the dynamic message, even core of   GM-I18n  system. It's really optimized (and will be even more optimized in the future, stay tuned!), so you can use it as much as you want.       You can use the    i18n_create_ref_message()  function to create a message reference in any variable, array, or struct. The   var_name  parameter is the name of the variable that will store the message reference.       You can use the   g.  shorthand for   global. . It's recommended to use   global.  for better readability, but it's up to you.       You can create the message reference in nested struct or array. Just make sure to pass the correct   var_name  to the    i18n_create_ref_message()  function.   Though it's a cool feature, it's not that flexible as you think. Here's some limitations you should be aware of:   You   can only  create the message reference in   global  variable or instance variable. You   can't  create it in the global function (in script asset), data structure (such as   ds_list ,   ds_map , etc.), or local variable. If you try to do so, it will return a static message instead of dynamic message, even if it's recognized by the system.  Currently, the message references created in array   only accept 1D array . So, you   can't  create it in   2D array or higher . Passing   text.0.1  as the   var_name  in the    i18n_create_ref_message()  function won't be recognized.  The system   only accept  array index (such as   text.0 ) in the   last level of the    var_name . So, struct inside an array (such as   text.0.button.text ) won't be recognized.    Though the     i18n_create_ref_message()    function is really optimized, don't ever create the message references in any event that updated every step (such as    Step Event ,   Draw Event  , etc.)! It will cause performance issue and may eventually crash your game.         If you want to create the message references in the    global    variable, do it in the    Create Event    of any object. If you want to create it in the instance variable, do it in the    Create Event    of the object that own the variable.        You need interpolate the message with certain value? Check out the   Interpolation  section!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":85,"path":86,"dir":77,"title":87,"description":88,"keywords":89,"body":94},"content:v1:3.usage:2.interpolation.md","/v1/usage/interpolation","Interpolation","Interpolation is a process of inserting some computed/dynamic values into a message. It's also known as variable substitution or string formatting in other localization system. It's a powerful feature that makes any internationalization system complete!",[90,91,92,93],"Indexed Data","Named Data","Linked Message","Summary","  Interpolation  Interpolation is a process of inserting some computed/dynamic values into a message. It's also known as   variable substitution  or   string formatting  in other localization system. It's a powerful feature that makes any internationalization system complete!  Let's say, you want to display a message that says   \"Hello John!\" . But instead of hardcoding the name   \"John\"  in the message, you want to make it dynamic so you can change the name later. That's where interpolation comes in handy!      // assume the system is initialized on global variable\n   normal_msg   =   i18n_get_messages  (  \"hello_normal\"  );                   // \"Hello John!\"\n   \n   player_name   =   \"John\"  ;\n   intp_msg   =   i18n_get_messages  (  \"hello_intp\"  , [player_name]);        // \"Hello John!\", {0} = \"John\" (player_name)\n     {\n       \"hello_normal\"  :   \"Hello John!\"  ,        // normal message\n       \"hello_intp\"  :   \"Hello {0}!\"            // message with interpolation\n   }\n     {\n       \"hello_normal\"  :   \"Halo John!\"  ,         // normal message\n       \"hello_intp\"  :   \"Halo {0}!\"             // message with interpolation\n   }\n  Message interpolation starts with a placeholder, which is a special string that will be replaced with the actual value. The placeholder is in the form of   {index}  for indexed data, and   {key}  for named data.   Indexed Data  Indexed data is the simplest and fastest form of interpolation. The data is in array form, and then you can use the index to insert the data into the message.   Format:   [data0, data1, data2, ...]    \nPlaceholder:   {0} ,   {1} ,   {2} , etc.   \nUsed In:    i18n_get_messages() ,    i18n_create_ref_message() ,    i18n_draw_message()      // assume the system is initialized on global variable\n   // i18n_get_messages(key, [data], [locale], [i18n])\n   // i18n_create_ref_message(var_name, key, [data], [i18n])\n   \n   // static messages\n   msg1   =   i18n_get_messages  (  \"hello\"  , [  \"John\"  ]);                      // \"Hello John!\"\n   msg2   =   i18n_get_messages  (  \"bye\"  , [  \"Selamat tinggal\"  ],   \"id\"  );       // \"Selamat tinggal Dunia!\"\n   \n   msg3   =   i18n_get_messages  (  \"welcome\"  , [         // \"Welcome to GM-I18n, Bro!\"\n       \"GM-I18n\"  ,   \"Bro\"                          // {0} = \"GM-I18n\", {1} = \"Bro\"\n   ]);\n   \n   intp_text   =   \"John\"  ;\n   msg4   =   [                                      // in array\n       i18n_get_messages  (  \"dialog.npc_4\"  , [       // \"Dia bilang, \"Selamat datang di desa John, {1}! Dah gitu aja, sekarang selamatkan temen gue!!!\"\"\n           intp_text                             // {0} = \"John\" (intp_text), {1} is not defined, so it won't be replaced\n       ],   \"id\"  )\n   ];\n   \n   nested   =   {                                            // in struct\n       msg5 :   i18n_get_messages  (  \"dialog.npc_1\"  , [        // \"I have 100 apples. Do you want to trade them with my 100 bamboos, John?\"\n           100  , intp_text,   \"apples\"                      // {0} = 100, {1} = \"John\" (intp_text), {2} = \"apple\"\n       ])\n   };\n   \n   \n   // dynamic messages, no difference with static messages \n   global.ref_msg1   =   i18n_create_ref_message  (  \"global.ref_msg1\"  ,   \"hello\"  , [  \"John\"  ]);\n   global.ref_msg2   =   i18n_create_ref_message  (  \"g.ref_msg2\"  ,   \"bye\"  , [  \"Selamat tinggal\"  ],   \"id\"  );\n   \n   ref_msg3   =   i18n_create_ref_message  (  \"ref_msg3\"  ,   \"welcome\"  , [\n       \"GM-I18n\"  ,   \"Bro\"\n   ]);\n   \n   ref_msg4   =   [\n       i18n_create_ref_message  (  \"ref_msg4.0\"  ,   \"dialog.npc_4\"  , [intp_text])\n   ];\n   \n   global.nested   =   {\n       ref_msg5 :   i18n_create_ref_message  (  \"global.nested.ref_msg5\"  ,   \"dialog.npc_1\"  , [\n           100  , intp_text,   \"apples\"\n       ])\n   };\n     // change the locale\n   // i18n_set_locale(code, [update_refs], [i18n])\n   i18n_set_locale  (  \"id\"  );                            // all message references will be updated automatically\n     {\n       \"hello\"  :   \"Hello {0}!\"  ,\n       \"bye\"  :   \"{1} World!\"  ,\n       \"welcome\"  :   \"Welcome to {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"I have {0} {2}. Do you want to trade them with my {0} bamboos, {1}?\"  ,\n           \"npc_4\"  :   \"He said,   \\\"  Welcome to our {1} village, {0}! That's all, now save my friend!!!  \\\"  \"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo {0}!\"  ,\n       \"bye\"  :   \"{1} Dunia!\"  ,\n       \"welcome\"  :   \"Selamat datang di {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Aku punya {0} {2}. Mau tukeran sama aku dengan {0} bambu, {1}?\"  ,\n           \"npc_4\"  :   \"Dia bilang,   \\\"  Selamat datang di desa {1}, {0}! Dah gitu aja, sekarang selamatkan temen gue!!!  \\\"  \"\n       }\n   }\n   The index starts from   0 . You can use the same index for multiple placeholder. For example, you can use   {0}  for multiple placeholder, and then pass only one data to the   data  parameter.   The data you passed to the   data  parameter on    i18n_create_ref_message()  function is   copied  to the message reference and become   static . So, if you change the value of the data after creating the message reference, it won't affect the data in the message.       The indexed data is the fastest form of interpolation. But it's not flexible enough if you want to use advanced interpolation features, such as   linked message ,   pluralization , and   dictionary .       The next section will introduce you to the   named data  form of interpolation, which is more flexible and powerful.   It's a good practice to use the placeholder in   ascending order  (  {0} ,   {1} ,   {2} , etc.) and   don't skip any index  for better readability and faster translation process.   Named Data  Named data is the most flexible form of interpolation. The data is in struct form, and then you can use the key to insert the data into the message.   Format:   {key1: value1, key2: value2, key3: value3, ...}    \nPlaceholder:   {key1} ,   {key2} ,   {key3} , etc.   \nUsed In:    i18n_get_messages() ,    i18n_create_ref_message()      // assume the system is initialized on global variable\n   \n   // static messages\n   msg1   =   i18n_get_messages  (  \"hello\"  , {name:   \"John\"  });                      // \"Hello John!\"\n   msg2   =   i18n_get_messages  (  \"bye\"  , {text:   \"Selamat tinggal\"  },   \"id\"  );       // \"Selamat tinggal Dunia!\"\n   \n   msg3   =   i18n_get_messages  (  \"welcome\"  , {         // \"Welcome to GM-I18n, Bro!\"\n       title:   \"GM-I18n\"  , \n       who:   \"Bro\"\n   });\n   \n   intp_text   =   \"John\"  ;\n   msg4   =   [\n       i18n_get_messages  (  \"dialog.npc_4\"  , {       // \"Dia bilang, \"Selamat datang di desa John, {1}! Dah gitu aja, sekarang selamatkan temen gue!!!\"\"\n           name: intp_text                       // {name} = \"John\" (intp_text), {village} is not defined, so it won't be replaced                 \n       },   \"id\"  );\n   ];\n   \n   \n   \n   msg5   =   i18n_get_messages  (  \"dialog.npc_1\"  , {        // \"I have 100 apples. Do you want to trade them with your 100 bamboos, John?\"\n       count:   100  , \n       name: intp_text, \n       item:   \"apples\"\n   });\n   \n   // dynamic messages, no difference with static messages \n   global.ref_msg1   =   i18n_create_ref_message  (  \"global.ref_msg1\"  ,   \"hello\"  , {name:   \"John\"  });\n   global.ref_msg2   =   i18n_create_ref_message  (  \"g.ref_msg2\"  ,   \"bye\"  , {name:   \"Selamat tinggal\"  },   \"id\"  );\n   \n   ref_msg3   =   i18n_create_ref_message  (  \"ref_msg3\"  ,   \"welcome\"  , {\n       title:   \"GM-I18n\"  , \n       who:   \"Bro\"\n   });\n   \n   ref_msg4   =   [\n       i18n_create_ref_message  (  \"ref_msg4.0\"  ,   \"dialog.npc_4\"  , {\n           name: intp_text, \n           village:   \"John\"\n       })\n   ];\n   \n   global.nested   =   {\n       ref_msg5 :   i18n_create_ref_message  (  \"global.nested.ref_msg5\"  ,   \"dialog.npc_1\"  , {\n           count:   100  , \n           name: intp_text, \n           item:   \"apples\"\n       })\n   };\n     {\n       \"hello\"  :   \"Hello {name}!\"  ,\n       \"bye\"  :   \"{text} World!\"  ,\n       \"welcome\"  :   \"Welcome to {title}, {who}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"I have {count} {item}. Do you want to trade them with your {count} bamboos, {name}?\"  ,\n           \"npc_4\"  :   \"He said,   \\\"  Welcome to our {village} village, {name}! That's all, now save my friend!!!  \\\"  \"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo {name}!\"  ,\n       \"bye\"  :   \"{text} Dunia!\"  ,\n       \"welcome\"  :   \"Selamat datang di {title}, {who}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Aku punya {count} {item}. Mau tukeran sama aku dengan {count} bambumu, {name}?\"  ,\n           \"npc_4\"  :   \"Dia bilang,   \\\"  Selamat datang di desa {village}, {name}! Dah gitu aja, sekarang selamatkan temen gue!!!  \\\"  \"\n       }\n   }\n   You can use the same key for multiple placeholder. For example, you can use   {text}  for multiple placeholder, and then pass only one data to the   data  parameter.       The key is case-sensitive. So,   {text}  and   {Text}  are different keys.       You can set the key like you're setting a variable name. So, need to follow the variable naming convention. You can use alphanumeric character and underscore, but can't start with a number.   The data you passed to the   data  parameter on    i18n_create_ref_message()  function is   copied  to the message reference and become   static . So, if you change the value of the data after creating the message reference, it won't affect the data in the message.       You   can't  mix the   indexed data  and   named data  in the same message. You need to choose one of them, because the structure of the data is different. If you try to do so, the placeholder (such as   {0} ) will be treated as a normal text .       The named data is the most flexible form of interpolation, but can be   too complex  to manage if you have a lot of data or very deep nesting. You can see the example in the   Nested Message Data  section.       You   can't  pass a named data on    i18n_draw_message()  function, because the    i18n_draw_message()  function only supports indexed data for the interpolation. You can use the    i18n_get_messages()  or    i18n_get_ref_message()  function to get the message first, and then pass the message to the    i18n_draw_message()  or   draw_text_*  function.    You can't use    plural ,   plural_value ,   child ,   and    child_*    as the key for the named data. They are reserved for the system.   Linked Message  Linked message is a special form of message that can link to another message. It's useful if you want to reuse a message in another message, so you don't have to duplicate the message.   Format:   [[key1]] [[key2]] [[key3]] ...    \nPlaceholder:   [[key1]] ,   [[key2]] ,   [[key3]] , etc.   \nUsed In:   [locale].json      // assume the system is initialized on global variable\n   // i18n_get_messages(key, [data], [locale], [i18n])\n   // i18n_create_ref_message(var_name, key, [data], [i18n])\n   \n   // static messages\n   msg1   =   i18n_get_messages  (  \"dialog.npc_3\"  );             // \"Hope you enjoy your stay in [[village_1.name]]!\", raw message, even there's a linked message\n   msg2   =   i18n_get_messages  (  \"dialog.npc_3\"  , {});         // \"Hope you enjoy your stay in Sukamakan!\", need to pass a named data (even empty) to activate the linked message\n   \n   player_name   =   \"John\"  ;\n   msg3   =   i18n_get_messages  (  \"welcome\"  , {who:   \"Bro\"  });                    // \"Welcome to Sukamakan, Bro!\", [[village_1.name]] = \"Sukamakan\"\n   msg4   =   i18n_get_messages  (  \"welcome\"  , {who: player_name},   \"id\"  );        // \"Selamat datang di Sukamakan, John!\"\n   \n   count   =   10  ;\n   msg5   =   [                                      // in an array\n       i18n_get_messages  (  \"dialog.npc_2\"  , {       // \"I have 10 Swords. Do you want to trade them with your 100 Bamboos, John?\"\n           count1 : count,                       // {count1} = 10 (count), {count2} = 100 (count * 10), {name} = \"John\" (player_name)\n           name: player_name,                    // [[items.sword]] = \"Sword\", [[items.bamboo]] = \"Bamboo\"\n           count2 : count   *   10\n       })\n   ];\n   \n   msg_struct   =   {                                        // in a struct\n       msg6 :   i18n_get_messages  (  \"items.letter\"  , {        // a deeply nested message, but it's just a string replacement\n           who: player_name                              // {who} won't be replaced, even though you've passed the data\n       })                                                // do you know why?\n   };                                             \n   /*\n    * \"Announcement:\"\n    * \"Welcome to Sukamakan, {who}! I'm Budiman of Sukamakan. Hope you enjoy your stay in Sukamakan!\"\n    */\n   \n   \n   // dynamic messages, no difference with static messages \n   global.ref_msg1   =   i18n_create_ref_message  (  \"global.ref_msg1\"  ,   \"dialog.npc_3\"  );\n   global.ref_msg2   =   i18n_create_ref_message  (  \"g.ref_msg2\"  ,   \"dialog.npc_3\"  , {},   \"id\"  );\n   \n   ref_msg3   =   i18n_create_ref_message  (  \"ref_msg3\"  ,   \"welcome\"  , {\n       who:   \"Bro\"\n   });\n   \n   ref_msg4   =   [\n       \"My string\"  ,\n       \"Other string\"  ,\n       i18n_create_ref_message  (  \"ref_msg4.2\"  ,   \"dialog.npc_2\"  , {\n           count1 : count, \n           name: player_name, \n           count2 : count   *   10\n       })\n   ];\n   \n   global.nested   =   {\n       ref_msg5 :   i18n_create_ref_message  (  \"global.nested.ref_msg5\"  ,   \"items.letter\"  , {\n           who: player_name\n       })\n   };\n     {\n       \"welcome\"  :   \"Welcome to [[village_1.name]], {who}!\"  ,\n       \"items\"  : {\n           \"apple\"  :   \"Apple\"  ,\n           \"bamboo\"  :   \"Bamboo\"  ,\n           \"sword\"  :   \"Sword\"  ,\n           \"shield\"  :   \"Shield\"  ,\n           \"potion\"  :   \"Potion\"  ,\n           \"letter\"  :   \"Announcement:  \\n\\\"  [[dialog.npc_1]]  \\\"  \"\n       },\n       \"dialog\"  : {\n           \"npc_1\"  :   \"[[welcome]] I'm [[village_1.chieftain]] of [[village_1.name]]. [[dialog.npc_3]]\"  ,\n           \"npc_2\"  :   \"I have {count1} [[items.sword]]s. Do you want to trade them with your {count2} [[items.bamboo]]s, {name}?\"  ,\n           \"npc_3\"  :   \"Hope you enjoy your stay in [[village_1.name]]!\"\n       },\n       \"village_1\"  : {\n           \"name\"  :   \"Sukamakan\"  ,\n           \"chieftain\"  :   \"Budiman\"  ,\n           \"trait\"  : {\n               \"num_1\"  :   \"Lots of food\"  ,\n               \"num_2\"  :   \"Love eating {item}\"  ,\n               \"num_3\"  :   \"{adj} people\"\n           }\n       }\n   }\n     {\n       \"welcome\"  :   \"Selamat datang di [[village_1.name]], {who}!\"  ,\n       \"items\"  : {\n           \"apple\"  :   \"Apel\"  ,\n           \"bamboo\"  :   \"Bambu\"  ,\n           \"sword\"  :   \"Pedang\"  ,\n           \"shield\"  :   \"Perisai\"  ,\n           \"potion\"  :   \"Ramuan\"  ,\n           \"letter\"  :   \"Pengumuman:  \\n\\\"  [[dialog.npc_1]]  \\\"  \"\n       },\n       \"dialog\"  : {\n           \"npc_1\"  :   \"[[welcome]] Aku adalah [[village_1.chieftain]] dari [[village_1.name]]. [[dialog.npc_3]]\"  ,\n           \"npc_2\"  :   \"Aku punya {count1} [[items.sword]]. Mau tukeran sama aku dengan {count2} [[items.bamboo]]mu, {name}?\"  ,\n           \"npc_3\"  :   \"Semoga betah di [[village_1.name]]!\"\n       },\n       \"village_1\"  : {\n           \"name\"  :   \"Sukamakan\"  ,\n           \"chieftain\"  :   \"Budiman\"  ,\n           \"trait\"  : {\n               \"num_1\"  :   \"Banyak makanan\"  ,\n               \"num_2\"  :   \"Suka makan {item}\"  ,\n               \"num_3\"  :   \"Orang yang {adj}\"\n           }\n       }\n   }\n   Linked message is regarded as   named data . Take a note that the placeholder (such as   [[welcome]] ) is the   actual key of the message  you want to link to. It's case-sensitive. So,   [[key1]]  and   [[Key1]]  are different keys.       You can customize the placeholder format in the    i18n_create()  function, so that you can change the opening (default:   [ ) and closing (default:   ] ) character, such as   \u003C\u003Ckey1>>  or   ::key1## . See the   API Reference  for more information.   Same as other form of interpolation, the linked message is   static . So, if you change the value of the data after creating the message reference, it won't affect the data in the message.       You   can't  mix the   indexed data  and   named data  in the same message. You need to choose one of them, because the structure of the data is different. If you try to do so, the linked message (such as   [[key1]] ) will be treated as a normal text.       The more deep the linked message is, the more painful it is to manage the data. It's not recommended to have a very deep linked message if you're also passing a lot of data (trust me on this one). You can see the example in the   Nested Message Data  section.   Summary  There are 3 forms of message data interpolation that you can use in GM-I18n:     Indexed Data  (  {0} ,   {1} ,   {2} , etc.)    Named Data  (  {key1} ,   {key2} ,   {key3} , etc.)    Linked Message  (  [[key1]] ,   [[key2]] ,   [[key3]] , etc.)  You can use any of them in any form of message (static or dynamic). You can use any interpolation form on any level of the message, even in the   nested/linked messages !  The   indexed data  is the simplest and fastest form of interpolation. But you can't use it with advanced interpolation features, such as   linked message ,   pluralization , and   dictionary .  The   named data  is more flexible than the indexed data. You can use it with   linked message ,   pluralization , and   dictionary . But it's a bit slower than the indexed data.  Use these form of interpolation based on your needs. If you want to use the   linked message ,   pluralization , and   dictionary  features, you need to use the   named data . If you don't, you can use the   indexed data  for better performance.       If you've mastered the message interpolation, you've already mastered the most important part of GM-I18n system!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":96,"path":97,"dir":77,"title":98,"description":99,"keywords":100,"body":103},"content:v1:3.usage:3.pluralization.md","/v1/usage/pluralization","Pluralization","Pluralization is a process of handling the plural form of a word. It's also known as plural handling or plural form in other localization system. It's also a powerful feature that makes any internationalization system complete!",[101,102,93],"Static Pluralization","Dynamic Pluralization","  Pluralization  Pluralization is a process of handling the plural form of a word. It's also known as   plural handling  or   plural form  in other localization system. It's also a powerful feature that makes any internationalization system complete!  Let's say, you have a message that says \"You have   {plural_value}  apple\". It's correct if you have only one apple. But if you have more than one apple, it should be \"You have   {plural_value}  apple   s \", right? That's where pluralization comes in handy!   Static Pluralization  GM-I18n provides a simple pluralization feature that can handle the plural form of a word/phrase in the message.   Format:   form0 | form1 | ...    \nAccess:   \u003Cindex>  or   {plural: \u003Cindex>}    \nUsed In:    i18n_get_messages() ,    i18n_create_ref_message() ,    i18n_draw_message()  For the static pluralization, the simplest way, you need to provide 2 forms of the word/phrase in the message. Generally, the first form is for singular, and the second form is for plural. And then you can pass the index of the form you want to use in the data.      // assume the system is initialized on global variable\n   // i18n_get_messages(key, [data], [locale], [i18n], [create_cache])\n   // i18n_create_ref_message(var_name, key, [data], [i18n])\n   \n   // static messages, static pluralization\n   msg1   =   i18n_get_messages  (  \"have_apple\"  );               // \"You don't have any apple | You have apple(s)\", raw message\n   \n   msg2   =   [                                              // in an array\n       i18n_get_messages  (  \"have_apple\"  ,   0  )                // \"You don't have any apple\", 0 = directly use the first form\n   ];  \n   \n   msg3   =   {                                                          // in a struct\n       my_msg :   i18n_get_messages  (  \"have_apple\"  ,   1  ,   \"id\"  );            // \"Kamu punya apel\", 1 = directly use the second form\n   }; \n   \n   msg4   =   i18n_get_messages  (  \"have_apple_cnt\"  , {plural:   1  });          // \"I have 1 apple\", {plural: 1} = use the second form through the `plural` key\n   msg5   =   i18n_get_messages  (  \"have_apple_cnt\"  , {                      // \"I have 10 apples\", {plural: 2} = use the third form, {count: 10} = replace the {plural_value} placeholder\n       plural :   2  ,                                                   // need to set the index value of the `plural` key manually\n       plural_value :   10                                             // interpolate the {plural_value} placeholder\n   });\n   \n   // dynamic messages, static pluralization, no difference with static messages \n   global.ref_msg1   =   i18n_create_ref_message  (  \"global.ref_msg1\"  ,   \"have_apple\"  );\n   \n   global.ref_msg2   =   [\n       i18n_create_ref_message  (  \"g.ref_msg2.0\"  ,   \"have_apple\"  ,   0  )\n   ];\n   \n   ref_msg3   =   {\n       my_msg :   i18n_create_ref_message  (  \"ref_msg3.my_msg\"  ,   \"have_apple\"  ,   1  ,   \"id\"  )\n   }\n   \n   global.ref_msg4   =   i18n_create_ref_message  (  \"global.ref_msg4\"  ,   \"have_apple_cnt\"  , {plural:   1  });\n   ref_msg5   =   i18n_create_ref_message  (  \"ref_msg5\"  ,   \"have_apple_cnt\"  , {\n       plural :   2  , \n       plural_value :   10\n   });\n     {\n       \"have_apple\"  :   \"You don't have any apple | You have apple(s)\"  ,\n       \"have_apple_cnt\"  :   \"I don't have any apple | I have 1 apple | I have {plural_value} apples\"\n   }\n     {\n       \"have_apple\"  :   \"Kamu tidak punya apel | Kamu punya apel\"  ,\n       \"have_apple_cnt\"  :   \"Aku tidak punya apel | Aku punya 1 apel | Aku punya {plural_value} apel\"\n   }\n   You can use the   \u003Cindex>  or   {plural: \u003Cindex>}  to access the plural form. Both are valid. But it's recommended to use the   {plural: \u003Cindex>}  because it's more readable and flexible. You can see the example in the next section.        The plural form is   static . So, if you change the value of the   plural  key after creating the message, it won't affect the plural form in the message.       You   can't  use the pluralization feature with the   indexed data . You need to use the   named data  instead. See the   Interpolation  section for more information.   Dynamic Pluralization  Dynamic pluralization use the same format as static pluralization, but the forms are   dynamic . So, you can change the plural form in the message, even after creating the message.   Format:   form0 | form1 | ...    \nAccess:   \u003Cindex>  or   {plural: \u003Cindex>}  or   {plural: \u003Cfunction>, plural_value: \u003Cvalue>}    \nUsed In:    i18n_get_messages() ,    i18n_create_ref_message() ,    i18n_draw_message()  You can make your own pluralization rule in the   plural  key in the named data. The function will be called with the   plural_value  as the parameter, and then it will return the   index  of the plural form you want to use. It's great for complex pluralization rule!  In Static Messages  This method is quite easy to implement the dynamic pluralization. You just need to   update  the message   every step , and the pluralization will be updated automatically based on your pluralization rule.    Pros:   Quite easy to implement.  No need to create the message reference.  Can be used in anywhere in the game, just like a static message.    Cons:   Need to update the message every step (may cause performance issue).  Only support with direct pluralization (by passing   \u003Cindex>  to the   data  parameter in the message).  Not suitable for complex pluralization rule.  No natural support for interpolated, linked, or nested message.      // assume the system is initialized on global variable\n   \n   // the value to be passed to the pluralization function\n   apple_count   =   0  ;\n   plural_index   =   0  ;\n   \n   // a simple method for pluralization rule\n   plural_rule   =   function  () {      \n       // modify the plural_index based on the apple_count value\n       plural_index   =   !  apple_count   ?   0   :   1  ;\n   }\n   \n   \n   // static messages in instance variable\n   msg1   =   i18n_get_messages  (  \"have_apple_cnt\"  ,   0  ,   \"en\"  );          // \"I don't have any apple\", will updated in Step Event\n   \n   msg2   =   [\n       \"\"                                                        // empty string, will updated in Step Event\n   ];\n   \n   msg3   =   {\n       my_msg :   i18n_get_messages  (  \"confirm\"  ,   0  ,   \"en\"  )            // \"No\", will updated in Step Event\n   };\n   \n   // static messages in global variable\n   global.my_msg   =   i18n_get_messages  (  \"have_apple_cnt\"  , {\n       plural :   0  ,                                               // \"Aku tidak punya apel\", will updated in Step Event\n       plural_value : apple_count\n   },   \"id\"  );   \n   \n   global.my_arr   =   [\n       i18n_get_messages  (  \"shop.buy\"  , plural_index,   \"en\"  )         // \"Buy 1 {name}? | Buy {plural_value} {name}{suffix}?\", will updated in Step Event\n   ];\n   \n   global.my_struct   =   {\n       my_msg :   i18n_get_messages  (  \"confirm\"  ,   1  ,   \"en\"  )            // \"Yes\", will updated in Step Event\n   };\n     // update the message every step, so the pluralization will be updated automatically\n   // only applicable for static messages\n   \n   msg1   =   i18n_get_messages  (  \"have_apple_cnt\"  ,                    // simple pluralization rule\n       (  !  apple_count   ?   0   :   (apple_count   ==   1   ?   1   :   2  )),          // if apple_count is 0, use the first form (index 0). if apple_count is 1, use the second form (index 1). otherwise, use the third form (index 2)\n   \"en\"  );                                                        // will change to \"I don't have any apple\", \"I have 1 apple\", or \"I have {plural_value} apples\" based on the apple_count value\n   \n   msg2[  0  ]   =   i18n_get_messages  (  \"shop.buy\"  ,\n       (apple_count   ==   1   ?   0   :   1  ),                               // if apple_count is 1, use the first form. otherwise, use the second form\n   \"en\"  );                                                        // will change to \"Buy 1 {name}?\" or \"Buy {plural_value} {name}{suffix}?\" based on the apple_count value\n   \n   msg3.my_msg   =   i18n_get_messages  (  \"confirm\"  ,\n       (apple_count   >=   10   ?   0   :   1  ),                              // if apple_count is 10 or more, use the first form. otherwise, use the second form\n   \"en\"  );                                                        // will change to \"No\" or \"Yes\" based on the apple_count value\n   \n   global.my_msg   =   i18n_get_messages  (  \"have_apple_cnt\"  , {         // passing a struct as the data in event that update every step is DISCOURAGED!\n       plural : (apple_count   ==   0   ?   0   :   1  ),                      // if apple_count is 0, use the first form. otherwise, use the second form\n       plural_value : apple_count                                // interpolate the {plural_value} placeholder\n   },   \"id\"  );                                                     // will change to \"Aku tidak punya apel\" or \"Aku punya {plural_value} apel\" (interpolated) based on the apple_count value\n   \n   global.my_arr[  0  ]   =   i18n_get_messages  (  \"shop.buy\"  , plural_index,   \"en\"  );\n   \n   global.my_struct.my_msg   =   i18n_get_messages  (  \"confirm\"  ,\n       (apple_count   >=   10   ?   0   :   1  ),\n   \"en\"  );\n     // increase the apple count\n   apple_count  ++  ;\n   \n   // call the pluralization rule\n   plural_rule  ();\n     // decrease the apple count\n   apple_count  --  ;\n   \n   // call the pluralization rule\n   plural_rule  ();\n     {\n       \"have_apple_cnt\"  :   \"I don't have any apple | I have 1 apple | I have {plural_value} apples\"  ,\n       \"confirm\"  :   \"No | Yes\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Your {resc} is\"  ,\n           \"buy\"  :   \"Buy 1 {name}? | Buy {plural_value} {name}{suffix}?\"  ,\n           \"confirm\"  :   \"[[shop.template_1]]n't enough to buy {name} | [[shop.template_1]] enough to buy 1 {name} | [[shop.template_1]] enough to buy {plural_value} {name}{suffix}\"\n       }\n   }\n     {\n       \"have_apple_cnt\"  :   \"Aku tidak punya apel | Aku punya {plural_value} apel\"  ,\n       \"confirm\"  :   \"Tidak | Ya\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"{resc} kamu\"  ,\n           \"buy\"  :   \"Beli 1 {name}? | Beli {plural_value} {name}?\"  ,\n           \"confirm\"  :   \"[[shop.template_1]] tidak cukup untuk membeli {name} | [[shop.template_1]] cukup untuk membeli {plural_value} {name}\"\n       }\n   \n   }\n   The pluralization function (ternary operator in the example above) is called every time you update the message. So, it's better to make the function as simple as possible to avoid performance issue.       You can also store a value in a variable (such as   plural_index ), and then pass the variable to the   data  parameter.   The static pluralization is not suitable for complex pluralization rule. Each language has its own pluralization rule, and it's impossible to cover all of them with a simple function.  Using Direct Drawing  This method is the simplest and quickest way to implement the dynamic pluralization. You just need to pass the   plural index  (or a simple function that return the index) and the   key message  to the    i18n_draw_message()  function.    Pros:   Super easy and quick to implement. Good choice if you only need to draw the message.  No need to create the message reference, not even create a variable for storing the message.  Can draw a static or dynamic message, with static or dynamic pluralization.    Cons:   Only used for drawing the message. The   Draw Event  or   Draw GUI Event  is the only place you can use this method.  May cause a   performance issue  if you have a lot of message keys in that locale (like, 1000+ keys in a locale).  Only support with direct pluralization (by passing   \u003Cindex>  to the   data  parameter in the message).  Not suitable for complex pluralization rule.  No natural support for interpolated, linked, or nested message.      // assume the system is initialized on global variable\n   \n   // the value to be passed to the pluralization function\n   apple_count   =   0  ;\n   plural_index   =   0  ;\n   \n   // a simple method for pluralization rule\n   plural_rule   =   function  () {      \n       // modify the plural_index based on the apple_count value\n       plural_index   =   !  apple_count   ?   0   :   1  ;\n   }\n     // i18n_draw_message(x, y, text, [data], [locale], [i18n])\n   \n   // static message and pluralization\n   i18n_draw_message  (  100  ,   50  ,   \"@:have_apple_cnt\"  ,   0  ,   \"en\"  );          // \"I don't have any apple\", will always use the first form (index 0)\n   \n   // static message and dynamic pluralization\n   i18n_draw_message  (  100  ,   50  ,   \"@:confirm\"  , plural_index,   \"id\"  );      // \"Tidak\" if plural_index is 0, or \"Ya\" if plural_index is 1\n   \n   i18n_draw_message  (  100  ,   50  ,   \"@:have_apple_cnt\"  ,\n       (  !  apple_count   ?   0   :   (apple_count   ==   1   ?   1   :   2  )),              // \"I don't have any apple\" if apple_count is 0, \"I have 1 apple\" if apple_count is 1, \"I have {plural_value} apples\" otherwise (not interpolated)\n   \"en\"  );\n   \n   i18n_draw_message  (  100  ,   50  ,   \"@:have_apple_cnt\"  , {                  // passing a struct as the data in event that update every step is DISCOURAGED!\n       plural : (apple_count   ==   0   ?   0   :   1  ),                          // \"Aku tidak punya apel\" if apple_count is 0, \"Aku punya {plural_value} apel\" otherwise (interpolated)\n       plural_value : apple_count\n   },   \"id\"  );\n   \n   // dynamic message and pluralization\n   i18n_draw_message  (  100  ,   50  ,   \"@:confirm\"  , (plural_index   ==   1  ));     // \"No\" / \"Tidak\" if plural_index is 0, or \"Yes\" / \"Ya\" if plural_index is 1\n   \n   i18n_draw_message  (  100  ,   50  ,   \"@:shop.buy\"  , \n       (apple_count   ==   1   ?   0   :   1  )                                    // if apple_count is 1, use the first form. otherwise, use the second form\n   );\n   \n   i18n_draw_message  (  100  ,   50  ,   \"@:have_apple_cnt\"  , \n       (  i18n_get_locale  ()   ==   \"en\"                                    // a bit complex pluralization rule\n           ?   (  !  apple_count   ?   0   :   (apple_count   ==   1   ?   1   :   2  ))         // rule for en locale: \"I don't have any apple\" if apple_count is 0, \"I have 1 apple\" if apple_count is 1, \"I have {plural_value} apples\" otherwise (not interpolated)\n           :   (apple_count   >=   1   ?   1   :   0  ))                             // rule for other locale (id): \"Aku punya {plural_value} apel\" if apple_count is 1 or more (not interpolated)\n   );\n     // increase the apple count\n   apple_count  ++  ;\n   \n   // call the pluralization rule\n   plural_rule  ();\n     // decrease the apple count\n   apple_count  --  ;\n     \n   // call the pluralization rule\n   plural_rule  ();\n     {\n       \"have_apple_cnt\"  :   \"I don't have any apple | I have 1 apple | I have {plural_value} apples\"  ,\n       \"confirm\"  :   \"No | Yes\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Your {resc} is\"  ,\n           \"buy\"  :   \"Buy 1 {name}? | Buy {plural_value} {name}{suffix}?\"  ,\n           \"confirm\"  :   \"[[shop.template_1]]n't enough to buy {name} | [[shop.template_1]] enough to buy 1 {name} | [[shop.template_1]] enough to buy {plural_value} {name}{suffix}\"\n       }\n   }\n     {\n       \"have_apple_cnt\"  :   \"Aku tidak punya apel | Aku punya {plural_value} apel\"  ,\n       \"confirm\"  :   \"Tidak | Ya\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"{resc} kamu\"  ,\n           \"buy\"  :   \"Beli 1 {name}? | Beli {plural_value} {name}?\"  ,\n           \"confirm\"  :   \"[[shop.template_1]] tidak cukup untuk membeli {name} | [[shop.template_1]] cukup untuk membeli {plural_value} {name}\"\n       }\n   \n   }\n   You can add   @:  prefix to the   text  parameter in the    i18n_draw_message()  function to use the message key instead of the actual text. It's useful if you want to use the same message key in different locale (so it become a dynamic message). See the example above.       The pluralization function (ternary operator in the example above) is called every time you draw the message. So, it's better to make the function as simple as possible to avoid performance issue.       You can also store a value in a variable (such as   plural_index ), and then pass the variable to the   data  parameter.   The direct drawing is   not suitable  for complex pluralization rule. Each language has its own pluralization rule, and it's impossible to cover all of them with a simple function.       The dynamic message in this method come with a performance cost. GM-I18n system will lookup the message from the locale data every time you draw the message. So, use it wisely.  Using Message Reference  This method is the most flexible and powerful way to implement the dynamic pluralization. It's recommended for you to implement the dynamic pluralization with this method.    Pros:   A true dynamic message.  Really flexible and powerful to implement the dynamic pluralization.  Suitable for complex pluralization rule.  Can apply interpolation, linked message, and nested message.  Really fast performance. The message is only lookup once, and then it will be updated if the locale is changed.  For the pluralization, you don't need to call the update function every time you want to update the message. Just update the data (  plural_value ), and the message will be updated automatically.    Cons:   Take more effort to implement.  The pluralization rule may be a bit complex if you want to support multiple locale.  You need to manage the message reference yourself (such as updating the data).      // assume the system is initialized on global variable\n   \n   // the value to be passed to the pluralization function\n   apple_count   =   0  ;\n   plural_index   =   0  ;\n   \n   // dynamic messages and pluralization\n   // in instance variable\n   ref_msg1   =   i18n_create_ref_message  (  \"simple_ref\"  ,   \"confirm\"  , {\n       plural  :   function  (  plural_value  ) {                              // the function for simple pluralization rule\n           return   plural_value   >=   10   ?   0   :   1  ;                        // if plural_value is 10 or more, use the first form (index 0). otherwise, use the second form (index 1)\n       },\n       plural_value: apple_count                                     // the value to be passed to the pluralization function\n   });\n   \n   // in global variable\n   global.ref_msg2   =   i18n_create_ref_message  (  \"global.ref_msg1\"  ,   \"have_apple_cnt\"  , {\n       plural  :   function  (  plural_value  ) {                                              // the function for complex pluralization rule, you need to make 1 parameter to pass the `plural_value` \n           if   (  i18n_get_locale  ()   ==   \"en\"  ) {                                          // en locale has 3 forms\n               return   !  plural_value   ?   0   :   (plural_value   ==   1   ?   1   :   2  );               // if plural_value is 0, use the first form (index 0). if plural_value is 1, use the second form (index 1). otherwise, use the third form (index 2)\n           }   else   if   (  i18n_get_locale  ()   ==   \"id\"  ) {                                   // id locale has only 2 forms\n               return   !  plural_value   ?   0   :   1  ;                                         // if plural_value is 0, use the first form (index 0). otherwise, use the second form (index 1)\n           }\n       },\n       plural_value: apple_count                                                     // the value to be passed to the pluralization function\n   });\n   \n   // in an array\n   ref_msg3   =   [\n       i18n_create_ref_message  (  \"ref_msg3.0\"  ,   \"shop.buy\"  , {\n           plural  :   function  (  plural_value  ) {\n               return   plural_value   ==   1   ?   0   :   1  ;                 // if plural_value is 1, use the first form (index 0). otherwise, use the second form (index 1)\n           },\n           plural_value: apple_count,                            // because we are using named data, the interpolation will work\n           name:   \"apple\"  ,                                        // if plural_value is 0, the message is \"Buy 1 apple?\" or \"Beli 1 apple?\" (the \"apple\" still in english!)\n           suffix:   \"s\"                                           // otherwise, the message is \"Buy {plural_value} apples?\" or \"Beli {plural_value} apple?\" (the {plural_value} is interpolated, but the \"apple\" still in english!})\n       })\n   ];\n   \n   // in a struct\n   global.ref_msg4   =   {\n       my_msg :   i18n_create_ref_message  (  \"g.ref_msg4.my_msg\"  ,   \"confirm\"  , {\n           plural  :   function  (  plural_value  ) {\n               return   plural_value   >=   10   ?   0   :   1  ;\n           },\n           plural_value: apple_count\n       }),\n       my_arr : [\n           i18n_create_ref_message  (  \"global.ref_msg4.my_arr.0\"  ,   \"shop.confirm\"  , {\n               plural  :   function  (  plural_value  ) {\n                   if   (  i18n_get_locale  ()   ==   \"en\"  ) {                                          // en locale has 3 forms\n                       return   !  plural_value   ?   0   :   (plural_value   ==   1   ?   1   :   2  );               // if plural_value is 0, use the first form (index 0). if plural_value is 1, use the second form (index 1). otherwise, use the third form (index 2)\n                   }   else   if   (  i18n_get_locale  ()   ==   \"id\"  ) {                                   // id locale has only 2 forms\n                       return   !  plural_value   ?   0   :   1  ;                                         // if plural_value is 0, use the first form (index 0). otherwise, use the second form (index 1)\n                   }\n               },\n               plural_value: apple_count,\n               name:   \"apple\"  ,\n               resc:   \"copper coin\"  ,\n               suffix:   \"s\"\n           })\n       ]\n   };\n   \n   // see the key pressed event for the update function\n     // increase the apple count\n   apple_count  ++  ;\n   \n   // i18n_update_plurals(var_name, plural_value, [update_refs], [i18n])\n   // update the plural value in the message reference\n   i18n_update_plurals  (  \"ref_msg1\"  , apple_count);                     // don't pass the `true` here \n   \n   // i18n_update_plurals(\"global.ref_msg2\", apple_count);         // in case you don't want to update the reference,\n                                                                   // just don't call the function\n                                                                   // for optimization, you should pass the `true` to update the reference, on the LAST message reference that you want to update\n   i18n_update_plurals  (  \"ref_msg3.0\"  , apple_count);                   // don't pass the `true` here\n   i18n_update_plurals  (  \"g.ref_msg4.my_msg\"  , apple_count);            // don't pass the `true` here too\n   i18n_update_plurals  (  \"g.ref_msg4.my_arr.0\"  , apple_count,   true  );    // pass the `true` here, because this is the LAST message reference that we want to update\n     // decrease the apple count\n   apple_count  --  ;\n   \n   // update the plural value in the message reference\n   i18n_update_plurals  (  \"global.ref_msg2\"  , apple_count,   true  );        // an example if you only want to update plural value on 1 reference\n     // change the locale\n   // i18n_set_locale(code, [update_refs], [i18n])\n   i18n_set_locale  ((  i18n_get_locale  ()   ==   \"en\"   ?   \"id\"   :   \"en\"  ));       // a simple locale switcher\n     {\n       \"have_apple_cnt\"  :   \"I don't have any apple | I have 1 apple | I have {plural_value} apples\"  ,\n       \"confirm\"  :   \"No | Yes\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Your {resc} is\"  ,\n           \"buy\"  :   \"Buy 1 {name}? | Buy {plural_value} {name}{suffix}?\"  ,\n           \"confirm\"  :   \"[[shop.template_1]]n't enough to buy {name} | [[shop.template_1]] enough to buy 1 {name} | [[shop.template_1]] enough to buy {plural_value} {name}{suffix}\"\n       }\n   }\n     {\n       \"have_apple_cnt\"  :   \"Aku tidak punya apel | Aku punya {plural_value} apel\"  ,\n       \"confirm\"  :   \"Tidak | Ya\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"{resc} kamu\"  ,\n           \"buy\"  :   \"Beli 1 {name}? | Beli {plural_value} {name}?\"  ,\n           \"confirm\"  :   \"[[shop.template_1]] tidak cukup untuk membeli {name} | [[shop.template_1]] cukup untuk membeli {plural_value} {name}\"\n       }\n   \n   }\n   Remember that the   plural  in the data is the rule that   return the index of the plural form  you want to use. You need to make sure that the function   have 1 parameter , and return the   correct index .       The   plural_value  is not limited to   number  type. You can use any data type that you want. For example, you can use   string ,   array ,   struct , etc. But of course, the simplest and most common type is a   number  type.       Though the   plural_value  is reserved for pluralization, you can still use it for interpolation as well.       You can get a dynamic interpolation by updating the   plural_value  in the message reference using    i18n_update_plurals()  function.       If you're using both pluralization and interpolation in the message, the system will process the   pluralization  first, and then the interpolation.   The   plural  and   plural_value  in the data is   reserved  for pluralization. You can't use it for other purpose.       You   need  to pass the   true  to the   update_refs  parameter in the    i18n_update_plurals()  function after you change the   plural_value  in the message reference. Otherwise, the message reference won't be updated. See the example in the   Key Pressed - Up  and   Key Pressed - Down  event.       For optimization, you   should only  pass the   true  to the   update_refs  parameter in the    i18n_update_plurals()  function on the   LAST  message reference that you want to update. Passing   true  on every    i18n_update_plurals()  function may cause performance issue. See the correct usage in the   Key Pressed - Up  and   Key Pressed - Down  event.         Don't call     i18n_update_plurals()    in any event that updated every step (such as   Step Event ,   Draw Event , etc.)! It may cause a performance issue, and it's even worse than updating the message every step.   Summary  There are 3 ways to implement the dynamic pluralization in GM-I18n. Each have their own pros and cons. You need to choose the one that best fit your needs, or just mix and match them!     Updating the Message Every Step   Pros: Quite easy to implement. No need to create the message reference.  Cons: Not suitable for complex pluralization rule. No natural support for interpolated, linked, or nested message.    Direct Drawing   Pros: Super easy and quick to implement. Good choice if you only need to draw the message.  Cons: Only used for drawing the message. Not suitable for complex pluralization rule. No natural support for interpolated, linked, or nested message.    Using Message Reference   Pros: The most flexible and powerful way to implement the pluralization. Suitable for complex pluralization rule. Have natural support for interpolated, linked, or nested message.  Cons: A bit more complex to implement. Need to create the message reference.  You   can't  use the pluralization feature with the   indexed data . You need to use the   named data  instead. See the   Interpolation  section for more information.  You need to return the   index of the plural form  in the   plural  function   explicitly  (such as   0  or   1 ). If you don't the system won't know which plural form you want to use. See the example above which return the explicit index in the   plural  function using ternary operator.  You can customize the starting pluralization index (default:   0 ) and the delimiter (default:   | ) in the    i18n_create()  function.       With pluralization, you can create a more natural and flexible message that can adapt to the user's input or game state. It's a powerful feature that can enhance the user experience in your game!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":105,"path":106,"dir":77,"title":107,"description":108,"keywords":109,"body":111},"content:v1:3.usage:4.drawing.md","/v1/usage/drawing","Drawing","Drawing is an important part of any game. In GM-I18n, you can draw the translated text using the i18n_draw_message() function. It's a wrapper for the draw_text_* functions with convenient additional features, so you can use it just like the draw_text_* functions.",[61,110],"Direct Drawing","  Drawing  Drawing is an important part of any game. In GM-I18n, you can draw the translated text using the    i18n_draw_message()  function. It's a wrapper for the   draw_text_*  functions with convenient additional features, so you can use it just like the   draw_text_*  functions.   Drawing Presets  Drawing presets are a way to store the drawing configuration so you can use it later. It's optional to use the drawing presets, but it's recommended to use it if you want to draw the translated text consistently.  Before we're creating the drawing presets, you need to create the font assets first. See the   Configuration  section for more information.  You done creating the font assets? Great! Let's familiarize ourselves with the constructor and most used functions for managing the drawing presets!  Constructor  I18nDrawings  Syntax     I18nDrawings  ([draw_font], [draw_halign], [draw_valign], [draw_color], [draw_scale], [draw_rotation], [draw_alpha], [text_sep], [text_width], [is_template])\n  Description   A constructor for creating a drawing preset. All parameters are optional.  Parameters     Name  Type  Default  Description    draw_font  Font Asset | String   undefined  The font to use in   draw_set_font()  function. If a string is provided, it will be converted to an asset index.   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.   is_template  Boolean   false  Whether the drawing preset is a template or not.  Returns     I18nDrawings  Examples     // only for explanation purpose, DON'T copy-paste this code\n   // title\n   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  );\n   \n   // header\n   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  );\n   \n   // body\n   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   32  ,   700  );\n   \n   // with other font\n   I18nDrawings  (fnRoboto, fa_right, fa_bottom, #  999999  ,   0.7  ,   0  ,   1  ,   -  1  ,   700  );\n   \n   // font asset created from code\n   I18nDrawings  (global.font_ja, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  );\n  Functions  i18n_add_drawings  Syntax     i18n_add_drawings  (locale, preset_name, data, [use_ref], [i18n]);\n  Description   Add one or more drawing preset to the selected locale(s).  Parameters     Name  Type  Default  Description    locale  String | String[]   The locale code to add the drawing preset(s). You can pass a string for single locale, or an array of string for multiple locales.   preset_name  String | String[]   The name of the drawing preset(s). You can pass a string for single preset, or an array of string for multiple presets.   data  I18nDrawings | I18nDrawings[]   The drawing preset data. You can pass a single    I18nDrawings  struct for single preset, or an array of    I18nDrawings  struct for multiple presets.   use_ref  Boolean   true  Use the first I18nDrawings struct as a reference, instead of creating a new one. Only works if the   locale  parameter is an array. Recommended to be   true  if you want to use the same drawing preset for multiple locales.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // add \"header\" drawing preset to \"en\" locale\n   i18n_add_drawings  (  \"en\"  ,   \"header\"  , \n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  )\n   );\n   \n   // add \"header\" drawing preset to \"en\" and \"id\" locales\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ],   \"header\"  , [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  )\n   ]);\n   \n   // same, but the \"en\" and \"id\" won't have the same struct reference\n   // only use this if you want to modify the drawing preset for each locale\n   // otherwise, keep the `use_ref` to `true`\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ],   \"header\"  , [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  )\n   ],   false  );\n   \n   // add \"header\" and \"body\" drawing presets to \"ja\" locale\n   i18n_add_drawings  (  \"ja\"  , [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (global.font_ja, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (global.font_ja, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n   \n   // add \"title\", \"header\", and \"body\" drawing presets to \"en\", \"id\", \"my\", and \"fr\" locales\n   // you're recommended to use this method if you want to use the same drawing preset for multiple locales\n   // the drawing presets only created once in \"en\" locale, and the rest of the locale will just reference the \"en\" locale\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ,   \"my\"  ,   \"fr\"  ], [  \"title\"  ,   \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n  i18n_use_drawing  Syntax     i18n_use_drawing  (preset_name, [locale], [i18n]);\n  Description   Use a drawing preset for the selected locale.  Parameters     Name  Type  Default  Description    preset_name  String   The name of the drawing preset to use.   locale  String   \"\"  The locale code to use the drawing preset. Leave it empty to mark it as   dynamic  locale.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns     I18nDrawings  or   Void  (if the drawing preset is not found)  Examples      // add some drawing presets\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ], [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n   \n   i18n_add_drawings  (  \"ja\"  , [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (global.font_ja, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (global.font_ja, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n     // use the \"header\" drawing preset from \"en\" locale\n   i18n_use_drawing  (  \"header\"  ,   \"en\"  );\n   \n   // use the \"body\" drawing preset from \"id\" locale\n   i18n_use_drawing  (  \"body\"  ,   \"id\"  );\n   \n   // use the \"header\" drawing preset from \"ja\" locale\n   i18n_use_drawing  (  \"header\"  ,   \"ja\"  );\n   \n   // use the \"body\" drawing preset for dynamic locale\n   i18n_use_drawing  (  \"body\"  );\n   Direct Drawing  After you creating the drawing presets, you can use it to draw the translated text. There are two ways to do it:   Using the    i18n_draw_message()  function. You'll get some benefit from using this function.  Using the    i18n_use_drawing()  function to change the drawing configuration, and then use the   draw_text_*  or    i18n_draw_message()  functions.   What's make the    i18n_draw_message()  function different from the   draw_text_*  functions?   Built-in support for the message key. You can pass the   message key  directly to the function, and it will automatically lookup the message from the locale data, making it a dynamic message without creating any message reference.  Built-in support for the drawing presets. You can easily change the   font ,   color ,   alignment , etc. by just passing the preset name to the function. See the   Drawing Presets  section for more information.  Built-in support for the message interpolation and pluralization. Just pass the   data  to the function, and the function will handle the rest. See the   Interpolation  section for more information.  Functions  i18n_draw_message  Syntax     i18n_draw_message  (x, y, text, [data], [preset_name], [locale], [i18n]);\n  Description   Draw a normal text or a translated text using the specified drawing preset.  Parameters     Name  Type  Default  Description    x  Real   The   x  position to draw the text.   y  Real   The   y  position to draw the text.   text  String   The text to draw. You can pass a normal text, or a message key (start with   @: ) to draw a translated text.   data  Integer | Any[]   undefined  The data to pass to the message   pluralization  (  Integer ) or   indexed interpolation  (  Any[] ).   preset_name  String   \"\"  The name of the drawing preset to use. Leave it empty to mark it as   dynamic  preset.   locale  String   \"\"  The locale code to use the drawing preset (and message key if the   text  parameter is a message key). Leave it empty if you don't want to use any drawing preset, or you want the message key to be static.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   my_msg   =   i18n_create_ref_message  (  \"my_msg\"  ,   \"hello\"  );\n   \n   // pluralization\n   plural_index   =   1  ;\n   \n   // indexed interpolation\n   player_name   =   \"John\"  ;\n   intp_data   =   [  \"GM-I18n\"  , player_name];\n   apple   =   {\n       cost :   999999  ,\n       resc :   \"copper coins\"\n   };\n   \n   // add some drawing presets\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ], [  \"title\"  ,   \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n   \n   i18n_add_drawings  (  \"ja\"  , [  \"title\"  ,   \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (global.font_ja, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  ),\n       new   I18nDrawings  (global.font_ja, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (global.font_ja, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n     // use the \"header\" drawing preset from \"en\" locale\n   i18n_use_drawing  (  \"header\"  ,   \"en\"  );\n   \n   // and then draw the message\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  );            // dynamic message based on \"hello\" key message\n   draw_text  (  100  ,   50  ,   \"Hello, GM-I18n User!\"  );       // static text, the drawing preset still applied\n   \n   // use `draw_set_*` function if you want\n   draw_set_font  (fnNotoSansBold);                // this font is static\n   draw_set_halign  (fa_right);\n   draw_set_valign  (fa_bottom);\n   draw_set_color  (c_red);\n   draw_set_alpha  (  0.5  );\n   i18n_draw_message  (  100  ,   50  ,   \"@:bye\"  );          // dynamic message based on \"bye\" key message, but with custom drawing configuration\n   \n   // this one is also a dynamic message using dynamic font\n   draw_set_font  (  i18n_get_drawings_data  (  \"header\"  ,   I18N_DRAWING  .  FONT  ));       // this font is dynamic, so it will be changed when the locale is changed\n   draw_text  (  100  ,   50  , my_msg);\n   \n   // draw a dynamic message (\"hello\" key message) using dynamic \"header\" drawing preset\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  , ,   \"header\"  );\n   \n   // draw a dynamic message (\"bye\" key message) using \"body\" drawing preset on \"en\" locale\n   i18n_draw_message  (  100  ,   50  ,   \"@:bye\"  , ,   \"body\"  ,   \"en\"  );\n   \n   // draw a static text using the latest drawing preset (\"body\")\n   i18n_draw_message  (  100  ,   50  ,   \"This is a static text\"  );\n   \n   // draw a static message (\"hello\" key message) using \"title\" drawing preset on \"ja\" locale\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  , ,   \"title\"  ,   \"ja\"  );\n   \n   // draw a static message (\"selection\" key message) using the latest drawing preset on \"id\" with static pluralization\n   i18n_draw_message  (  100  ,   50  ,   \"@:selection\"  ,   0  , ,   \"id\"  );\n   \n   // draw a dynamic message (\"selection\" key message) using \"header\" drawing preset with dynamic pluralization based on the `plural_index` value\n   // bad practice, because the the latest `i18n_draw_message()` function already change the drawing preset to \"title\"\n   i18n_draw_message  (  100  ,   50  ,   \"@:selection\"  , plural_index,   \"title\"  );\n   \n   // draw a dynamic message (\"welcome\" key message) using \"body\" drawing preset with indexed interpolation based on the `intp_data` value\n   i18n_draw_message  (  100  ,   50  ,   \"@:welcome\"  , intp_data,   \"body\"  );\n   \n   // draw a static message (\"welcome\" key message) using the latest drawing preset on \"en\" with indexed interpolation\n   i18n_draw_message  (  100  ,   50  ,   \"@:welcome\"  , [\n       \"GM-I18n\"  ,   \"Bro\"\n   ], ,   \"en\"  );\n   \n   // draw a dynamic message (\"dialog.npc_1\" key message) using \"header\" drawing preset with indexed interpolation\n   i18n_draw_message  (  100  ,   50  ,   \"@:dialog.npc_1\"  , [\n       apple.cost, apple.resc\n   ],   \"header\"  );\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Bye World!\"  ,\n       \"selection\"  :   \"No | Yes\"  ,\n       \"welcome\"  :   \"Welcome to {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"This   \\\"  Bad Apple  \\\"   is cost {0} {1}!\"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"selection\"  :   \"Tidak | Ya\"  ,\n       \"welcome\"  :   \"Selamat datang di {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"  \\\"  Bad Apple  \\\"   ini harganya {0} {1}!\"\n       }\n   }\n     {\n       \"hello\"  :   \"こんにちは世界！\"  ,\n       \"bye\"  :   \"さようなら世界！\"  ,\n       \"selection\"  :   \"いいえ | はい\"  ,\n       \"welcome\"  :   \"{1}、{0}へようこそ！\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"この  \\\"  Bad Apple  \\\"  は{0} {1}です！\"\n       }\n   }\n    Currently, the    i18n_draw_message()  function is the only way to directly draw the translated text in GM-I18n.       You can optimize the drawing process by using the drawing presets and templates. See the   Drawing Templates  section for more information.   Though it's really convenient, you shouldn't use    i18n_draw_message()  function too much if you want to optimize the performance.       The    i18n_draw_message()  function is not suitable for complex text drawing. For example, you can't use it to draw a text with multiple font size, color, or alignment in a single line.       Don't pass the same   preset_name  to the    i18n_draw_message()  function in sequential calls. It will call a redundant    i18n_use_drawing()  function, which is not efficient.       You can't use named data interpolation with the    i18n_draw_message()  function. You need to use the    i18n_get_messages()  or    i18n_get_ref_message()  function to get the message first, and then pass the message to the    i18n_draw_message()  or   draw_text_*  function.       With this section, you can draw translated texts with   consistent  style in your game!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":113,"path":114,"dir":77,"title":115,"description":116,"keywords":117,"body":119},"content:v1:3.usage:5.localized-assets.md","/v1/usage/localized-assets","Localized Assets","Localized assets are assets that have different versions based on the locale. This is useful when you want to display a different sprite for each locale, or you want to play a different sound for each locale.",[70,118],"Dynamic Assets Localization","  Localized Assets  Localized assets are assets that have different versions based on the locale. This is useful when you want to display a different sprite for each locale, or you want to play a different sound for each locale.  It can be a sprite, sound, or even other assets type you want to localize!   How It Works?  Let's see the example below to see the differences when you aren't using   GM-I18n 's localized assets and when you're using it.      // assume you're not using GM-I18n system, \n   // so you need to manually change the locale and the assets\n   locale   =   \"en\"  ;\n   my_spr   =   sprSplashEn;\n   my_snd   =   sndVoiceEn;\n     // change the locale and the assets\n   // and of course, you need to manually change the assets for each locale (really tiresome!)\n   if   (locale   ==   \"en\"  ) {\n       locale   =   \"id\"  ;\n       my_spr   =   sprSplashId;\n       my_snd   =   sndVoiceId;\n   }   else   {\n       locale   =   \"en\"  ;\n       my_spr   =   sprSplashEn;\n       my_snd   =   sndVoiceEn;\n   }\n     // play the sound\n   audio_play_sound  (my_snd,   1  ,   false  );\n     // draw the sprite\n   draw_sprite  (my_spr,   0  ,   100  ,   50  );\n   draw_sprite_ext  (my_spr,   0  ,   100  ,   200  ,   1  ,   1  ,   0  , c_white,   1  );\n  How about when you're using   GM-I18n 's localized assets?      // assume the system is initialized on global variable\n   // i18n_create_ref_asset(var_name, locale_asset, [i18n])\n   // just create the reference to the assets, like you're creating a message reference\n   my_spr   =   i18n_create_ref_asset  (  \"my_spr\"  , {\n       en: sprSplashEn,\n       id: sprSplashId\n   });\n   \n   my_snd   =   i18n_create_ref_asset  (  \"my_snd\"  , {\n       en: sndVoiceEn,\n       id: sndVoiceId\n   });\n     // change the locale, and the assets will be changed automatically!\n   i18n_set_locale  ((  i18n_get_locale  ()   ==   \"en\"   ?   \"id\"   :   \"en\"  ));           // a simple locale switcher\n     // play the sound\n   audio_play_sound  (my_snd,   1  ,   false  );\n     // draw the sprite\n   draw_sprite  (my_spr,   0  ,   100  ,   50  );\n   draw_sprite_ext  (my_spr,   0  ,   100  ,   200  ,   1  ,   1  ,   0  , c_white,   1  );\n   Dynamic Assets Localization  We won't discuss about static assets, because it's really simple and you don't even need to use   GM-I18n  for it. Just need to pass the asset ID to the function that needs it.  Let's dive into the dynamic assets localization using   GM-I18n !  Functions  You can create the asset reference using the    i18n_create_ref_asset()  function. The function is really similar to the    i18n_create_ref_message()  function. Here's some difference between them:   The    i18n_create_ref_asset()  function doesn't have the   key  parameter. You don't need to provide the key, because the key is the asset itself.  The    i18n_create_ref_asset()  function has the   locale_asset  parameter. You need to provide the asset for each locale in the struct. The struct key is the locale code, and the value is the asset ID.  i18n_create_ref_asset  Syntax     i18n_create_ref_asset  (var_name, locale_asset, [i18n]);\n  Description   Creates a reference to the localized asset. The reference will automatically update itself when the locale is changed by calling    i18n_set_locale()  function.  Parameters     Name  Type  Default  Description    var_name  String   The name of the variable that will store the asset reference. The   var_name  can be in any level of the instance variable or global variable.   locale_asset  Struct   The localized asset for each locale. The struct key is the locale code, and the value is the asset ID.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Asset  (in the   current locale  of the    I18n  struct)  Examples      // assume the system is initialized on global variable\n   \n   // create some asset references\n   // the `var_name` is the name of the variable that will store the asset reference\n   // for this example, we will use the `my_spr` variable to store the sprite reference\n   my_spr   =   i18n_create_ref_asset  (  \"my_spr\"  , {\n       en: sprSplashEn,\n       id: sprSplashId,\n       ja: sprSplashJa\n   });\n   \n   // you can create the reference in array\n   // add the index of the array to the `var_name` separated by dot \".\"\n   // so, the `var_name` is \"my_arr.0\"\n   my_arr   =   [\n       i18n_create_ref_asset  (  \"my_arr.0\"  , {\n           en: sndVoiceEn,\n           id: sndVoiceId,\n           ja: sndVoiceJa\n       })\n   ];\n   \n   // you can also create the reference in struct\n   // add the member name of the struct to the `var_name` separated by dot \".\" \n   // so, the `var_name` is \"my_struct.my_spr\" and \"my_struct.my_snd.0\"\n   my_struct   =   {\n       my_spr :   i18n_create_ref_asset  (  \"my_struct.my_spr\"  , {\n           en: sprTutorial1En,\n           id: sprTutorial1Id,\n           ja: sprTutorial1Ja\n       }),\n       my_snd : [\n           i18n_create_ref_asset  (  \"my_struct.my_snd.0\"  , {\n               en: sndVoiceEn,\n               id: sndVoiceId,\n               ja: sndVoiceJa\n           })\n       ]\n   };\n   \n   // in global variable, add \"global.\" or \"g.\" as the prefix\n   global.my_obj   =   i18n_create_ref_asset  (  \"global.my_obj\"  , {\n       en: objPlayerEn,\n       id: objPlayerId,\n       ja: objPlayerJa\n   });\n   \n   // you can also create the reference in array in global variable\n   global.my_room   =   [\n       i18n_create_ref_asset  (  \"g.my_room.0\"  , {\n           en: rmMainMenuEn,\n           id: rmMainMenuId,\n           ja: rmMainMenuJa\n       })\n   ];\n   \n   // you can also create the reference in struct in global variable, and even nested struct in global struct!\n   global.my_font   =   {\n       my_font_1 :   i18n_create_ref_asset  (  \"g.my_font.my_font_1\"  , {\n           en: fnNotoSansEn,\n           id: fnNotoSansId,\n           ja: fnNotoSansJa\n       }),\n       ui_font : [\n           i18n_create_ref_asset  (  \"global.my_font.ui_font.0\"  , {\n               en: fnNotoSansEn,\n               id: fnNotoSansId,\n               ja: fnNotoSansJa\n           })\n       ]\n   };\n     // change the locale, and the assets will be changed automatically!\n   i18n_set_locale  ((  i18n_get_locale  ()   ==   \"en\"   ?   \"id\"   :   \"en\"  ));           // a simple locale switcher\n     // play the sound\n   audio_play_sound  (my_arr[  0  ],   1  ,   false  );\n   audio_play_sound  (my_struct.my_snd[  0  ],   1  ,   false  );\n     // draw the sprite\n   draw_sprite  (my_spr,   0  ,   100  ,   50  );\n   draw_sprite_ext  (my_struct.my_spr,   0  ,   100  ,   200  ,   1  ,   1  ,   0  , c_white,   1  );\n   The   var_name  is   not  the name of the asset itself. You can name the   var_name  as you want, as long as it's unique in the same level of the variable.       You can see the detailed explanation in the   Variable Name Handling  section.   The asset you passed to the   locale_asset  parameter is   static . So, if you change the value of the asset after creating the asset reference, it won't affect the asset in the reference.       If you don't set the asset for a specific locale, the asset in the reference will be   undefined , and will take the asset in the default locale instead. So, make sure to set the asset for all locale you want to support.        That's it, you can create localized assets without breaking any sweat!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":121,"path":122,"dir":77,"title":123,"description":124,"keywords":125,"body":128},"content:v1:3.usage:6.locale-switching.md","/v1/usage/locale-switching","Locale Switching","I've set some available locales in the game, but how do I switch between them? Let's see how to do it with different methods!",[126,127],"How It Works","Locale Switcher","  Locale Switching  I've set some available locales in the game, but how do I switch between them? Let's see how to do it with different methods!   How It Works  Just call the    i18n_set_locale()  function with the locale code you want to switch to. It's that simple!  Functions  i18n_set_locale  Syntax     i18n_set_locale  (code, [update_refs], [i18n]);\n  Description   Change the current locale used by the   GM-I18n  system.  Parameters     Name  Type  Default  Description    code  String   The locale code to switch to.   update_refs  Boolean   true  Update all references (message and asset) to the new locale.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // assume the system is initialized on global variable\n   \n   i18n_set_locale  (  \"id\"  );            // switch to \"id\" locale, and update all references\n   \n   i18n_set_locale  (  \"en\"  ,   false  );     // switch to \"en\" locale, but don't update the references\n  That's it! Really simple, right?   Locale Switcher  You can use the    i18n_set_locale()  function to create a simple locale switcher.  Before we're jumping into the examples, let's make the message data first for this example! We will use the   en ,   id ,   ja , and   zh_CN  locales.      {\n       \"locale\"  : {\n           \"name\"  :   \"Language\"  ,\n           \"en\"  :   \"English\"  ,\n           \"id\"  :   \"Indonesian\"  ,\n           \"ja\"  :   \"Japanese\"\n       },\n       \"switch\"  :   \"Switch\"  ,\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Bye World!\"  ,\n       \"welcome\"  :   \"Welcome to {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"   : {\n               \"greeting\"  :   \"How are you today, {name}?\"  ,\n               \"farewell\"  :   \"See you later, {0}!\"\n           }\n       }\n   }\n     {\n       \"locale\"  : {\n           \"name\"  :   \"Bhs Indonesia\"  ,\n           \"en\"  :   \"Inggris\"  ,\n           \"id\"  :   \"Indonesia\"  ,\n           \"ja\"  :   \"Jepang\"\n       },\n       \"switch\"  :   \"Ganti\"  ,\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai Jumpa Dunia!\"  ,\n       \"welcome\"  :   \"Selamat datang di {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"   : {\n               \"greeting\"  :   \"Apa kabar hari ini, {name}?\"  ,\n               \"farewell\"  :   \"Jumpa lagi nanti, {0}!\"\n           }\n       }\n   }\n     {\n       \"locale\"  : {\n           \"name\"  :   \"言語\"  ,\n           \"en\"  :   \"英語\"  ,\n           \"id\"  :   \"インドネシア語\"  ,\n           \"ja\"  :   \"日本語\"\n       },\n       \"switch\"  :   \"切り替える\"  ,\n       \"hello\"  :   \"こんにちは世界！\"  ,\n       \"bye\"  :   \"さようなら世界！\"  ,\n       \"welcome\"  :   \"ようこそ{0}、{1}！\"  ,\n       \"dialog\"  : {\n           \"npc_1\"   : {\n               \"greeting\"  :   \"{name}、今日はどうですか？\"  ,\n               \"farewell\"  :   \"また後で、{0}！\"\n           }\n       }\n   }\n     {\n       \"locale\"  : {\n           \"name\"  :   \"语言\"  ,\n           \"en\"  :   \"英语\"  ,\n           \"id\"  :   \"印尼语\"  ,\n           \"ja\"  :   \"日语\"\n       },\n       \"switch\"  :   \"切换\"  ,\n       \"hello\"  :   \"你好世界！\"  ,\n       \"bye\"  :   \"再见世界！\"  ,\n       \"welcome\"  :   \"欢迎来到{0}，{1}！\"  ,\n       \"dialog\"  : {\n           \"npc_1\"   : {\n               \"greeting\"  :   \"{name}，你今天过得怎么样？\"  ,\n               \"farewell\"  :   \"再见，{0}！\"\n           }\n       }\n   }\n  Now let's create some locale switchers!  Cycling Stepper  The most basic switcher is just a simple   button  that changes the locale when clicked. This method is called   Cycling Stepper .   Change the available locale with one way cycle, for example:   en -> id -> ja -> zh_CN -> en .  objLocaleStepper  This object will be used to show the current locale name and change the locale when clicked.      // assume the system is initialized on global variable,\n   // the data has been loaded, and you've created the drawing preset\n   \n   // create the message reference for the locale name\n   ref_locale   =   i18n_create_ref_message  (  \"ref_locale\"  ,   \"locale.name\"  );\n     // draw the button\n   draw_self  ();\n   \n   // draw the current locale name (will be updated automatically when the locale is changed)\n   // using \"button\" drawing preset\n   i18n_draw_message  (x   +   (sprite_width   /   2  ), y   +   (sprite_height   /   2  ), ref_locale, ,   \"button\"  );\n     // change the locale when the button is clicked (left released)\n   \n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :   i18n_set_locale  (  \"id\"  );   break  ;\n       case   \"id\"  :   i18n_set_locale  (  \"ja\"  );   break  ;\n       case   \"ja\"  :   i18n_set_locale  (  \"zh_CN\"  );   break  ;\n       case   \"zh_CN\"  :   i18n_set_locale  (  \"en\"  );   break  ;\n   }\n  How simple, right? You can use the    i18n_get_locale()  function to get the current locale, and then use it to change the locale as you want.   Stepper  This method is similar to the   Cycling Stepper , but it can cycle the locale in both ways.   Change the available locale with two way cycle, for example:   en \u003C-> id \u003C-> ja \u003C-> zh_CN .  objLocaleStepper  This object will be used to show the current locale name and become the locale controller.      // assume the system is initialized on global variable,\n   // the data has been loaded, and you've created the drawing preset\n   \n   // create the message reference for the locale name\n   ref_locale   =   i18n_create_ref_message  (  \"ref_locale\"  ,   \"locale.name\"  );\n   \n   // create the locale controller\n   locale_codes   =   i18n_get_locales_code  ();           // get all locale codes\n   locale_index   =   0  ;                                 // current locale index\n   locale_count   =   array_length  (locale_codes);        // total locale count\n   \n   // create the stepper button\n   step_next   =   instance_create_depth  (x   +   (sprite_width   /   2  )   +   (  sprite_get_width  (objLocaleNext)   /   2  ), y, depth, objLocaleNext, {\n       target : id\n   });\n   \n   step_prev   =   instance_create_depth  (x   -   (sprite_width   /   2  )   -   (  sprite_get_width  (objLocalePrev)   /   2  ), y, depth, objLocalePrev, {\n       target : id\n   });\n     // draw the sprite\n   draw_self  ();\n   \n   // draw the current locale name (will be updated automatically when the locale is changed)\n   // using \"button\" drawing preset\n   i18n_draw_message  (x   +   (sprite_width   /   2  ), y   +   (sprite_height   /   2  ), ref_locale, ,   \"button\"  );\n  objLocalePrev  This object will be used to change the locale to the previous one.     // change the locale index to the previous one\n   if   (target.locale_index   >   0  ) {\n       target.locale_index  --  ;\n   }   else   {\n       target.locale_index   =   target.locale_count   -   1  ;\n   }\n   \n   // change the locale\n   i18n_set_locale  (target.locale_codes[target.locale_index]);\n  objLocaleNext  This object will be used to change the locale to the next one.     // change the locale index to the next one\n   if   (target.locale_index   \u003C   target.locale_count   -   1  ) {\n       target.locale_index  ++  ;\n   }   else   {\n       target.locale_index   =   0  ;\n   }\n   \n   // change the locale\n   i18n_set_locale  (target.locale_codes[target.locale_index]);\n  A bit complicated, but it's still simple, right?   Option Group  This method is used in    GM-I18n  demo . It's a bit more complicated than the previous methods, but it's more flexible.   Change the available locale with option group, for example:   en ,   id ,   ja ,   zh_CN .  objLocaleGroup  This object will be used to show the current locale name and become the locale controller.     // assume the system is initialized on global variable,\n   // the data has been loaded, and you've created the drawing preset\n   \n   // create the locale options\n   locale_codes   =   i18n_get_locales_code  ();           // get all locale codes\n   \n   for   (  var   i   =   0  ; i   \u003C   array_length  (locale_codes); i  ++  ) {\n       // create the locale option in vertical line\n       instance_create_depth  (x, y   +   (i   *   (  sprite_get_height  (objLocaleOption)   +   10  )), depth, objLocaleOption, {\n           code : locale_codes[i]\n       });\n   }\n  objLocaleOption  This object will be used to change the locale when clicked.      // assume the system is initialized on global variable,\n   // the data has been loaded, and you've created the drawing preset\n   \n   // get a static message for this locale\n   name   =   i18n_get_messages  (  \"locale.name\"  , , code);\n     // draw the sprite\n   draw_self  ();\n   \n   // draw the locale name using \"button\" drawing preset in the specific locale\n   i18n_draw_message  (x   +   (sprite_width   /   2  ), y   +   (sprite_height   /   2  ), name, ,   \"button\"  , code);\n     // change the locale\n   i18n_set_locale  (code);\n  This one is the most flexible one. You can improve this example to fit your needs. For example, you can add a   highlight  effect when the locale is active, or you can make a real dropdown menu for the locale options.   Custom  The example above are just some basic examples. Of course, you can create your own locale switcher! The possibilities are endless.  Use these functions to help you create your own locale switcher:     i18n_get_locales_code()  to get all available locale codes.    i18n_get_locale()  to get the current locale code.    i18n_set_locale()  to change the locale.   You can also use the    i18n_get_messages()  function to get a static message for each locale. It's useful if you want to show the locale name in the switcher.        That's it! How about adding this   locale switcher  to your game, especially in your   settings/options  menu?  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":130,"path":131,"dir":132,"title":133,"description":7,"keywords":134,"body":138},"content:v1:4.advanced:1.nested-message-data.md","/v1/advanced/nested-message-data","advanced","Nested Message Data",[135,136,137],"Data in Linked Messages","Default Child Data","Specific Child Data","  Nested Message Data   This section is a bit advanced. You can skip this section if you're not using the linked message.   You   need  to read about the   named data interpolation  and   linked message  first before you continue reading this section.  If you're using   linked message , you may want to pass a data to the linked message. For example, you have a message like this:      {\n       \"greet\"  :   \"Welcome to GM-I18n, {name}! [[greet2]]\"  ,\n       \"greet2\"  :   \"Hope this library useful for you, {who}!\"\n   }\n     {\n       \"greet\"  :   \"Selamat datang di GM-I18n, {name}! [[greet2]]\"  ,\n       \"greet2\"  :   \"Harap library ini bermanfaat untukmu, {who}!\"\n   }\n  And then you get the static message or create a message reference like this:     // assume the system is initialized on global variable\n   \n   // static message\n   my_msg   =   i18n_get_messages  (  \"greet\"  , {\n       name :   \"John\"  ,\n       who :   \"John\"\n   },   \"en\"  );\n   \n   // dynamic message\n   global.ref_msg   =   i18n_create_ref_message  (  \"global.ref_msg\"  ,   \"greet\"  , {\n       name :   \"John\"  ,\n       who :   \"John\"\n   });\n  The   my_msg  and   global.ref_msg  variable will return the same message:   Welcome to GM-I18n, John! Hope this library useful for you, {who}!  The   {who}  is   not  replaced, even though we've   passed  the data. Why is that? It's because the data is   not passed  to the   linked message . The data is only passed to the main message (  greet ), but not to the linked message (  greet2 ).   The   GM-I18n  system set this rule because:   It's   confusing . Should we pass the   data  to the main message, or to the linked message? What if we want to pass different data to the linked message?  It's   dangerous . What if the linked message is used in another message, but with different   data ? It will cause a   data collision . For example, in the example above, what if we're using the same placeholder (  {name} ) in the   greet2  instead of   {who} , but with different data?  It's   unnecessary . You can just pass the   data  to the linked message directly, without passing it to the main message first.  It's   not always needed . The linked message can be used without any   data , and it will still work as expected.  It's   not consistent . The linked message should be treated as a separate message, not as a part of the main message.   You'll only get this issue when you're using the   named data . The   indexed data  (  {0} ,   {1} ,   {2} , etc.) is not affected by this issue, because the indexed data   doesn't  support linked message.       You can still pass the data to the linked message, but you need to do it manually.   Data in Linked Messages  As I mentioned before, the linked messages should be treated as a separate message.  To pass the   data  to the linked message, you need to use a   child  or   child_*  key in the main message data.      // assume the system is initialized on global variable\n   \n   // static message\n   my_msg   =   i18n_get_messages  (  \"greet\"  , {\n       name :   \"John\"  ,                        // interpolate {name} in \"greet\" message\n                          \n       child : {                             // act as the \"data\" for the linked message\n           who :   \"John\"                      // interpolate {who} in \"greet2\" message\n       }\n   },   \"en\"  );\n   \n   // dynamic message\n   global.ref_msg   =   i18n_create_ref_message  (  \"global.ref_msg\"  ,   \"greet3\"  , {\n       user :   \"Reader of GM-I18n\"  ,           // interpolate {user} in \"greet3\" message\n   \n       child : {                             // works the same as the static message\n           user :   \"John\"                     // using the same key (`user`) is fine, because it's in different \"scope\"\n       }\n   });\n     {\n       \"greet\"  :   \"Welcome to GM-I18n, {name}! [[greet2]]\"  ,\n       \"greet2\"  :   \"Hope this library useful for you, {who}!\"  ,\n       \"greet3\"  :   \"Hello, {user}! This is a main message. [[greet4]]\"  ,\n       \"greet4\"  :   \"And this is a child message, {user}!\"\n   }\n     {\n       \"greet\"  :   \"Selamat datang di GM-I18n, {name}! [[greet2]]\"  ,\n       \"greet2\"  :   \"Harap library ini bermanfaat untukmu, {who}!\"  ,\n       \"greet3\"  :   \"Halo, {user}! Ini adalah pesan induk. [[greet4]]\"  ,\n       \"greet4\"  :   \"Dan ini adalah pesan anak, {user}!\"\n   }\n  That's the basic of passing data to the linked message. Are you ready for the next section?   Default Child Data  The   child  key is used to pass the data to   all  of the linked message in the main message. It's good choice if you want to pass the same data to all of the linked message.  Think the   child  key as an   else  block in an   if-else  statement, or a   default  keyword in a   switch  statement. You can override the default data by using the   child_*  key. But we will discuss about it in the   next section .      // assume the system is initialized on global variable\n   \n   // applicable on both static and dynamic message\n   // in this example, we will only focus on the data passing\n   \n   // no data passed\n   npc1   =   i18n_get_messages  (  \"dialog.npc_1\"  , ,   \"en\"  );         // return the raw string in `dialog.npc_1`, because the linked message is not activated\n   npc1   =   i18n_get_messages  (  \"dialog.npc_1\"  , {},   \"en\"  );       // remember, you still need to pass the data (struct), even if it's empty, to activate the linked message\n                                                           // \"Do you have 20 apples? How about trading them with me for 5 bamboos? \" (in English)\n   msg_arr   =   [\n       i18n_get_messages  (  \"welcome\"  , {                        // \"Selamat datang di desa Sukamakan, John! Harap betah di desa ini!\" (in Indonesian)\n           village:   \"Sukamakan\"  ,\n           name:   \"John\"\n       },   \"id\"  )\n   ];\n   \n   // only pass to the child message\n   npc2   =   i18n_create_ref_message  (  \"npc2\"  ,   \"dialog.npc_2\"  , {\n       child : {                                                 // pass the data to the child message (`item.apple_trait`, `item.bamboo_trait`, and `item.potion_trait`)\n           adj :   \"Shiny\"                                         // \"adj\" is the placeholder in those child messages\n       }                                                         // all of them will be replaced with \"Shiny\"\n   });\n   \n   global.npc3   =   i18n_get_messages  (  \"dialog.npc_3\"  , {\n       child : [  \"Fresh\"  ]                                         // using indexed data? why not? GM-I18n system accepts both named and indexed data in the `child` key\n   });                                                           // it's because the system treats the `child` key as a separate message\n   \n   // with pluralization\n   my_apple   =   10  ;\n   buy_apple   =   5  ;\n   confirm_buy   =   i18n_create_ref_message  (  \"confirm_buy\"  ,   \"shop.buyable\"  , {\n       plural  :   function  (  val  ) {\n           return   (val   >   1  )   ?   1   :   0  ;                     // explicitly return the index value\n       },\n       plural_value: my_apple,                           // the system will do the pluralization first before processing the `child` key\n       suffix:   \"s\"  ,\n       \n       child: {                                          // pass the data to the child message (`shop.template_1`)\n           count: buy_apple,                             // will return \"Are you sure you want to buy 5 Apples?\"\n           item:   i18n_get_messages  (  \"item.apple\"  )\n       }\n   });\n   \n   // nested child\n   global.npc_dialogs   =   {\n       npc4 :   i18n_create_ref_message  (  \"global.npc_dialogs.npc4\"  ,   \"dialog.npc_4.num_1\"  , {     // activate the `dialog.npc_4.num_2` linked message\n           child : {                             // activate the `welcome` child message\n               child : {                         // pass `village` and `name` to the `welcome` message \n                   village:   \"Sukamakan\"  ,         // and activate the `welcome_2` grandchild message\n                   name:   \"John\"\n               }\n           }\n       })\n   }\n     {\n       \"welcome\"  :   \"Welcome to {village} village, {name}! [[welcome_2]]\"  ,\n       \"welcome_2\"  :   \"Hope you enjoy your stay in this village!\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Are you sure you want to buy {count} {item}\"  ,\n           \"buyable\"  :   \"[[shop.template_1]]? | [[shop.template_1]]{suffix}?\"\n       },\n       \"item\"  : {\n           \"owned\"  :   \"You already have {count} {item}.\"  ,\n           \"not_owned\"  :   \"You don't have this {item}. [[shop.confirm]]\"  ,\n           \"apple\"  :   \"Apple\"  ,\n           \"apple_trait\"  :   \"{adj} Apple\"  ,\n           \"bamboo\"  :   \"Bamboo\"  ,\n           \"bamboo_trait\"  :   \"{adj} Bamboo\"  ,\n           \"potion\"  :   \"Potion\"  ,\n           \"potion_trait\"  :   \"{adj} Potion\"  ,\n           \"chicken\"  :   \"Chicken\"  ,\n           \"chicken_trait\"  :   \"{0} Chicken\"  ,\n           \"duck\"  :   \"Duck\"  ,\n           \"duck_trait\"  :   \"{0} Duck\"\n       },\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Do you have 20 [[item.apple]]s? How about trading them with me for 5 [[item.bamboo]]s?\"  ,\n           \"npc_2\"  :   \"Welcome to my shop! Take a look at this [[item.apple_trait]], [[item.bamboo_trait]], and [[item.potion_trait]]. Do you want to buy any of them?\"  ,\n           \"npc_3\"  :   \"Ah, how about [[item.chicken_trait]] and [[item.duck_trait]] then?\"  ,\n           \"npc_4\"  : {\n               \"num_1\"  :   \"Is this your first time to visit our village? [[dialog.npc_4.num_2]]\"  ,\n               \"num_2\"  :   \"Huh, really?  \\n  Then, [[welcome]]\"  ,\n           }\n       }\n   }\n     {\n       \"welcome\"  :   \"Selamat datang di desa {village}, {name}! [[welcome_2]]\"  ,\n       \"welcome_2\"  :   \"Harap betah di desa ini!\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Apakah kamu yakin ingin membeli {count} {item}\"  ,\n           \"buyable\"  :   \"[[shop.template_1]]? | [[shop.template_1]]{suffix}?\"\n       },\n       \"item\"  : {\n           \"owned\"  :   \"Kamu sudah memiliki {count} {item}.\"  ,\n           \"not_owned\"  :   \"Kamu tidak memiliki ini {item}. [[shop.confirm]]\"  ,\n           \"apple\"  :   \"Apel\"  ,\n           \"apple_trait\"  :   \"{adj} Apel\"  ,\n           \"bamboo\"  :   \"Bambu\"  ,\n           \"bamboo_trait\"  :   \"{adj} Bambu\"  ,\n           \"potion\"  :   \"Ramuan\"  ,\n           \"potion_trait\"  :   \"{adj} Ramuan\"  ,\n           \"chicken\"  :   \"Ayam\"  ,\n           \"chicken_trait\"  :   \"{0} Ayam\"  ,\n           \"duck\"  :   \"Bebek\"  ,\n           \"duck_trait\"  :   \"{0} Bebek\"\n       },\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Apakah kamu memiliki 20 [[item.apple]]? Bagaimana dengan menukar mereka dengan saya untuk 5 [[item.bamboo]]?\"  ,\n           \"npc_2\"  :   \"Selamat datang di toko saya! Lihatlah ini [[item.apple_trait]], [[item.bamboo_trait]], dan [[item.potion_trait]]. Apakah Anda ingin membeli salah satu dari mereka?\"  ,\n           \"npc_3\"  :   \"Ah, bagaimana dengan [[item.chicken_trait]] dan [[item.duck_trait]]?\"  ,\n           \"npc_4\"  : {\n               \"num_1\"  :   \"Apakah ini pertama kalinya kamu datang ke desa kami? [[dialog.npc_4.num_2]]\"  ,\n               \"num_2\"  :   \"Huh, benarkah?  \\n  Kalau begitu, [[welcome]]\"\n           }\n       }\n   }\n   You can nest the   child  key as deep as you want, but it's not recommended to have a very deep nesting, because it can be hard to manage the data. Just look at the example above, it's already   3 levels deep . It's already hard to read, right?   The pluralization works properly in the main message (either static or dynamic). But, if it goes to the   child message or deeper , the pluralization will only accept   static pluralization . So, even if you pass a function to the   plural  key (with   plural_value ) in the   child  data, it will only executed once (when the message is created), and can't be updated later using   i18n_update_plurals()  function.   Specific Child Data  The   child  key is used to pass the data to   all  of the linked message in the main message. But, what if you want to pass different data to different linked message?  You can use the   child_*  key to pass the data to the specific linked message. The   *  is the key of the linked message. For example, if you want to pass the data to the   greet2  linked message, you can use the   child_greet2  key.      // assume the system is initialized on global variable\n   \n   // applicable on both static and dynamic message\n   // in this example, we will only focus on the data passing\n   \n   // activate the linked message feature, but not passing any data to the linked message\n   msg_struct   =   {\n       my_msg :   i18n_get_messages  (  \"welcome\"  , {                   // \"Selamat datang di desa Sukamakan, Agus! Harap betah di desa ini!\" (in Indonesian)\n           village:   \"Sukamakan\"  ,\n           name:   \"Agus\"\n       },   \"id\"  )\n   };\n   \n   // only pass to the child message\n   npc2   =   i18n_create_ref_message  (  \"npc2\"  ,   \"dialog.npc_2\"  , {\n       // specific child data\n       child_item_apple_trait : {                                // pass the data to the `item.apple_trait` linked message\n           adj:   \"Bad\"                                            // \"adj\" is the placeholder in the `item.apple_trait` message\n       },                                                        // the {adj} placeholder in this linked message will be replaced with \"Bad\"\n       child_item_bamboo_trait : {\n           adj:   \"Premium\"\n       },\n   \n       // default child data\n       child : {                                                 // will only be applied to the `item.bamboo_trait` and `item.potion_trait` linked messages\n           adj :   \"Shiny\"                                         // the {adj} placeholder all of those non-specified child data will be replaced with \"Shiny\"\n       }                                                         // \"Welcome to my shop! Take a look at this Bad Apple, Premium Bamboo, and Shiny Potion. Do you want to buy any of them?\"\n   });\n   \n   global.npc3   =   i18n_get_messages  (  \"dialog.npc_3\"  , {             // for specified child data in indexed data message, you can just use a diferent index value\n       child : [  \"Fresh\"  ,   \"Beautiful\"  ]                            // {0} is \"Fresh\", {1} is \"Beautiful\"\n   });                                                           // \"Ah, how about Fresh Chicken and Beautiful Duck then?\"\n   \n   // with pluralization\n   my_coins   =   global.coins;                                      // assume you have declared `global.coins` somewhere in your code\n   buy_resc   =   \"Copper Coin\"  ;\n   \n   confirm_buy   =   i18n_create_ref_message  (  \"confirm_buy\"  ,   \"dialog.npc_5\"  , {\n       plural  :   function  (  val  ) {\n           return   (val   >=   500  )   ?   1   :   0  ;                  // explicitly return the index value\n       },                                                // use form 2 (index 1) if the player have 500 coins or more, otherwise use form 1 (index 0)\n       plural_value: my_coins,\n       resc: buy_resc,\n       \n       // pass a data to `item.bamboo_trait` child message\n       child_item_bamboo_trait: {\n           adj:   \"Premium\"\n       },\n       \n       // pass a data to other child message\n       child: {\n           adj:   \"Legendary\"\n       }\n   });\n   \n   // nested child\n   global.npc_dialogs   =   {\n       npc4 :   i18n_create_ref_message  (  \"global.npc_dialogs.npc4\"  ,   \"dialog.npc_4.num_1\"  , {     // activate the `dialog.npc_4.num_2` linked message\n           child : {                             // activate the `welcome` child message\n               child_welcome : {                 // pass `village` and `name` to the `welcome` message \n                   village:   \"Sukamakan\"  ,         // there's no `child` key, but it still work as long as you use the `child_*` key\n                   name:   \"John\"\n               }\n           }\n       })\n   }\n     {\n       \"welcome\"  :   \"Welcome to {village} village, {name}! [[welcome_2]]\"  ,\n       \"welcome_2\"  :   \"Hope you enjoy your stay in this village!\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Are you sure you want to buy {count} {item}\"  ,\n           \"buyable\"  :   \"[[shop.template_1]]? | [[shop.template_1]]{suffix}?\"\n       },\n       \"item\"  : {\n           \"owned\"  :   \"You already have {count} {item}.\"  ,\n           \"not_owned\"  :   \"You don't have this {item}. [[shop.confirm]]\"  ,\n           \"apple\"  :   \"Apple\"  ,\n           \"apple_trait\"  :   \"{adj} Apple\"  ,\n           \"bamboo\"  :   \"Bamboo\"  ,\n           \"bamboo_trait\"  :   \"{adj} Bamboo\"  ,\n           \"potion\"  :   \"Potion\"  ,\n           \"potion_trait\"  :   \"{adj} Potion\"  ,\n           \"chicken\"  :   \"Chicken\"  ,\n           \"chicken_trait\"  :   \"{0} Chicken\"  ,\n           \"duck\"  :   \"Duck\"  ,\n           \"duck_trait\"  :   \"{1} Duck\"\n       },\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Do you have 20 [[item.apple]]s? How about trading them with me for 5 [[item.bamboo]]s?\"  ,\n           \"npc_2\"  :   \"Welcome to my shop! Take a look at this [[item.apple_trait]], [[item.bamboo_trait]], and [[item.potion_trait]]. Do you want to buy any of them?\"  ,\n           \"npc_3\"  :   \"Ah, how about [[item.chicken_trait]] and [[item.duck_trait]] then?\"  ,\n           \"npc_4\"  : {\n               \"num_1\"  :   \"Is this your first time to visit our village? [[dialog.npc_4.num_2]]\"  ,\n               \"num_2\"  :   \"Huh, really?  \\n  Then, [[welcome]]\"  ,\n           },\n           \"npc_5\"  :   \"Sorry, your {resc}s is not enough to buy this [[item.bamboo_trait]]. | Do you want to buy [[item.bamboo_trait]] for {plural_value} {resc}s, sir? I'll add a [[item.apple_trait]] for you as a bonus!\"\n       }\n   }\n     {\n       \"welcome\"  :   \"Selamat datang di desa {village}, {name}! [[welcome_2]]\"  ,\n       \"welcome_2\"  :   \"Harap betah di desa ini!\"  ,\n       \"shop\"  : {\n           \"template_1\"  :   \"Apakah kamu yakin ingin membeli {count} {item}\"  ,\n           \"buyable\"  :   \"[[shop.template_1]]? | [[shop.template_1]]{suffix}?\"\n       },\n       \"item\"  : {\n           \"owned\"  :   \"Kamu sudah memiliki {count} {item}.\"  ,\n           \"not_owned\"  :   \"Kamu tidak memiliki ini {item}. [[shop.confirm]]\"  ,\n           \"apple\"  :   \"Apel\"  ,\n           \"apple_trait\"  :   \"{adj} Apel\"  ,\n           \"bamboo\"  :   \"Bambu\"  ,\n           \"bamboo_trait\"  :   \"{adj} Bambu\"  ,\n           \"potion\"  :   \"Ramuan\"  ,\n           \"potion_trait\"  :   \"{adj} Ramuan\"  ,\n           \"chicken\"  :   \"Ayam\"  ,\n           \"chicken_trait\"  :   \"{0} Ayam\"  ,\n           \"duck\"  :   \"Bebek\"  ,\n           \"duck_trait\"  :   \"{1} Bebek\"\n       },\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Apakah kamu memiliki 20 [[item.apple]]? Bagaimana dengan menukar mereka dengan saya untuk 5 [[item.bamboo]]?\"  ,\n           \"npc_2\"  :   \"Selamat datang di toko saya! Lihatlah ini [[item.apple_trait]], [[item.bamboo_trait]], dan [[item.potion_trait]]. Apakah Anda ingin membeli salah satu dari mereka?\"  ,\n           \"npc_3\"  :   \"Ah, bagaimana dengan [[item.chicken_trait]] dan [[item.duck_trait]]?\"  ,\n           \"npc_4\"  : {\n               \"num_1\"  :   \"Apakah ini pertama kalinya kamu datang ke desa kami? [[dialog.npc_4.num_2]]\"  ,\n               \"num_2\"  :   \"Huh, benarkah?  \\n  Kalau begitu, [[welcome]]\"\n           },\n           \"npc_5\"  :   \"Maaf, {resc} kamu tidak cukup untuk membeli ini [[item.bamboo_trait]]. | Apakah kamu ingin membeli [[item.bamboo_trait]] dengan harga {plural_value} {resc}, tuan? Aku akan menambahkan satu [[item.apple_trait]] untuk kamu sebagai bonus!\"  ,\n       }\n   }\n   You can use both   child  and   child_*  keys at the same time, either static or dynamic message. Use those as efficient as possible.       As you can see in the example above, the   dot separator  (  [key].[subkey] ) of the message key used in   child_*  is replaced by   underscore  (  [key]_[subkey] ). You need to follow this rule to make sure the   child_*  key works properly.       The   child_*  key can be defined in the   main message  or in the   child message . You can even define 2 or more   child_*  key, like you're using   if-else  statement.       You can also use the   child_*  key in the   child message or deeper , but it's not recommended to have a very deep nesting, because it can be hard to manage the data.   Same as the   default child data , the pluralization works properly in the main message (either static or dynamic). But, if it goes to the   child message or deeper , the pluralization will only accept   static pluralization . So, even if you pass a function to the   plural  key (with   plural_value ) in the   child  data, it will only executed once (when the message is created), and can't be updated later using    i18n_update_plurals()  function.        It seems   hard  to understand for the first time. But, don't worry, it will be   easier  as you go along!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":140,"path":141,"dir":132,"title":142,"description":143,"keywords":144,"body":147},"content:v1:4.advanced:2.dictionaries.md","/v1/advanced/dictionaries","Dictionaries","Dictionaries are also a core of the GM-I18n system. They are used to translating your messages furtherly, so your message will appear in very natural way.",[126,145,146],"Registering Dictionaries","Using Dictionaries","  Dictionaries  Dictionaries are also a   core  of the   GM-I18n  system. They are used to translating your messages furtherly, so your message will appear in very natural way.   Do I need to use dictionaries?  Let's see the example below first before you answer.      // assume you've initialized the i18n system\n   \n   text   =   i18n_create_ref_message  (  \"text\"  ,   \"ask\"  , {       // create message ref with \"ask\" key\n       item:   \"apple\"                                     // and pass the required data\n   });\n     // change the locale\n   \n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :   i18n_set_locale  (  \"id\"  );   break  ;\n       case   \"id\"  :   i18n_set_locale  (  \"ja\"  );   break  ;\n       case   \"ja\"  :   i18n_set_locale  (  \"en\"  );   break  ;\n   }\n     {\n       \"ask\"  :   \"Do you want this {item}?\"\n   }\n     {\n       \"ask\"  :   \"Apakah kamu ingin {item} ini?\"\n   }\n     {\n       \"ask\"  :   \"この{item}が欲しいですか？\"\n   }\n  The expected result is:    en  : Do you want this apple?   id  : Apakah kamu ingin    apple  ini?   ja  : この   apple が欲しいですか？  Well, how do you think? The interpolation works, but it's not natural, right? The   apple  is not translated, it's just passed as it is. That's where dictionaries come in!  You can now answer the previous question,   do I need to use dictionaries?   How It Works  Here's a simple example of how dictionaries work:   Get a message using    i18n_get_messages() , or create a message reference using    i18n_create_ref_message() .  Pass the   data  on the message or message reference. In the example above, we pass the   item  data.  The system checks if the   item  data value (  apple ) is registered in the   dictionary  of the used locale.  If it is, the system will use the   dictionary value  instead of the data value. If it's not, the system will use the data value as is.   Registering Dictionaries  You can register dictionaries using the    i18n_add_dictionaries()  function. It's similar to    i18n_add_messages() , but it's only accepts data in array format, where each item is a pair of key and value, like   [\"key\", \"value\"] .  You can also register multiple dictionaries at once by passing an array of pairs, like   [\"key1\", \"value1\"], [\"key2\", \"value2\"] .  Functions  i18n_add_dictionaries  Syntax     i18n_add_dictionaries  (locale, data, [i18n]);\n  Description   Adds dictionaries to the specified locale.  Parameters     Name  Type  Default  Description    locale  String   The locale to add the dictionaries to.   data  [String, String] | [String, String][]   The dictionaries to add with [\"key\", value] pair, or array of [\"key\", value] pair.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // add \"apple\" -> \"apel\" dictionary to \"id\" locale\n   i18n_add_dictionaries  (  \"id\"  , [  \"apple\"  ,   \"apel\"  ]);\n   \n   // add more dictionaries to \"id\" locale\n   i18n_add_dictionaries  (  \"id\"  , [\n       [  \"banana\"  ,   \"pisang\"  ],\n       [  \"orange\"  ,   \"jeruk\"  ],\n       [  \"one\"  ,   \"satu\"  ],\n       [  \"two\"  ,   \"dua\"  ],\n       [  \"three\"  ,   \"tiga\"  ]\n   ]);\n   \n   // add dictionaries to \"ja\" locale\n   i18n_add_dictionaries  (  \"ja\"  , [\n       [  \"apple\"  ,   \"リンゴ\"  ],\n       [  \"banana\"  ,   \"バナナ\"  ],\n       [  \"orange\"  ,   \"オレンジ\"  ],\n       [  \"one\"  ,   \"一\"  ],\n       [  \"two\"  ,   \"二\"  ],\n       [  \"three\"  ,   \"三\"  ]\n   ]);\n   \n   // you can add number as well\n   i18n_add_dictionaries  (  \"ar\"  , [\n       [  \"1\"  ,   \"١\"  ],\n       [  \"2\"  ,   \"٢\"  ],\n       [  \"3\"  ,   \"٣\"  ],\n       [  \"4\"  ,   \"٤\"  ],\n       [  \"5\"  ,   \"٥\"  ]\n   ]);\n   \n   // you can also add dictionaries for the default locale (en), or variant of it\n   i18n_add_dictionaries  (  \"en_GB\"  , [\n       [  \"soccer\"  ,   \"football\"  ],\n       [  \"cookie\"  ,   \"biscuit\"  ],\n       [  \"fries\"  ,   \"chips\"  ]\n   ])\n   \n   // key-value pair is also supported\n   i18n_add_dictionaries  (  \"en\"  , [\n       [  \"hello\"  ,   \"Hello World!\"  ],\n       [  \"btn.cancel\"  ,   \"Cancel\"  ],\n       [  \"btn.yes\"  ,   \"Yes\"  ],\n       [  \"btn.no\"  ,   \"No\"  ]\n   ]);\n   \n   // you can make it as a glossary-like dictionaries\n   i18n_add_dictionaries  (  \"en\"  , [\n       [  \"Cure\"  ,   \"A beginner skill of a healer that heals a single target.\"  ],\n       [  \"Will of the Adventurer\"  ,   \"A skill that increases the user's attack power by 10% for 30 seconds.\"  ],\n       [  \"Fireball\"  ,   \"A powerful fire spell that deals damage to all enemies in a small area.\"  ],\n       [  \"Potion\"  ,   \"A consumable item that restores 50 HP when used.\"  ],\n       [  \"Elixir\"  ,   \"A consumable item that restores 100 MP when used.\"  ],\n       [  \"Mana Potion\"  ,   \"A consumable item that restores 50 MP when used.\"  ],\n       [  \"Phoenix Down\"  ,   \"An item that revives a fallen ally with 50% HP.\"  ],\n       [  \"Ether\"  ,   \"An item that restores 30 MP to an ally.\"  ]\n   ]);\n   You normally register dictionaries for   other locales  than the default locale (in this case,   en ), so you can use the    i18n_add_dictionaries()  function to register dictionaries for   id  and   ja  locales as shown in the example above.       You can also register dictionaries for the default locale. Maybe, you want to override the default dictionary value for some reason.   If you register a dictionary with the same key as an existing one, it will   override  the existing value. So, be careful when registering dictionaries.       The   key  is case-sensitive, so   apple  and   Apple  are considered different keys. It also only accept   String  as the key.   Using Dictionaries  The dictionaries won't be used automatically. You need to add   $  prefix to the named data in the message reference or message, like   ${item} . The system will then check if the value of   {item}  is registered in the dictionaries of the current locale. If it is, the system will use the dictionary value instead of the data value.   Format:   ${data_name}    \nPlaceholder:   ${data_name1} ,   ${data_name2} , etc.   \nUsed In:   [locale].json  Here's an example of how to use it:      // assume you've initialized the i18n system\n   \n   // add the required dictionaries\n   i18n_add_dictionaries  (  \"en\"  , [\n       [  \"item.map\"  ,   \"Village Map\"  ],\n       [  \"apple_box\"  ,   \"box of apples\"  ],\n       [  \"Will of the Adventurer\"  ,   \"A skill that increases the user's attack power by 10% for 30 seconds\"  ]\n   ]);\n   \n   i18n_add_dictionaries  (  \"id\"  , [\n       [  \"ticket\"  ,   \"tiket\"  ],\n       [  \"apple\"  ,   \"apel\"  ],\n       [  \"item.map\"  ,   \"Peta Desa\"  ],\n       [  \"apple_box\"  ,   \"kotak apel\"  ],\n       [  \"Will of the Adventurer\"  ,   \"Keterampilan yang meningkatkan kekuatan serangan pengguna sebesar 10% selama 30 detik\"  ]\n   ]);\n   \n   i18n_add_dictionaries  (  \"ja\"  , [\n       [  \"ticket\"  ,   \"チケット\"  ],\n       [  \"apple\"  ,   \"リンゴ\"  ],\n       [  \"item.map\"  ,   \"村の地図\"  ],\n       [  \"apple_box\"  ,   \"リンゴの箱\"  ],\n       [  \"Will of the Adventurer\"  ,   \"ユーザーの攻撃力を30秒間10%上昇させるスキル\"  ]\n   ]);\n   \n   \n   // on static message\n   ask1   =   i18n_get_messages  (  \"ask\"  , {         // \"ask\" key\n       item:   \"apple\"                         // pass the required data without dictionary\n   },   \"id\"  );                                 // \"Apakah kamu ingin apple ini?\" (\"apple\" is not translated)\n   \n   ask2   =   i18n_get_messages  (  \"ask_2\"  , {       // \"ask_2\" key\n       item:   \"apple\"                         // pass the required data with dictionary (add `$` prefix before the data name)\n   },   \"id\"  );                                 // \"Apakah kamu ingin apel ini?\" (natural translation)\n                                           // \"apple\" -> \"apel\" (from \"id\" dictionary)\n   \n   player_name   =   \"John\"  ;\n   \n   // on message reference\n   npc1   =   i18n_create_ref_message  (  \"npc1\"  ,   \"dialog.npc_1\"  , {\n       chief_name :   \"Budi\"                   // \"Budi\" is not registered in any dictionary\n   });                                       // so, it will be used as is (chief_name: \"Budi\")\n                                           // `en` : \"Please ask Budi for help.\"\n   \n   my_struct   =   {\n       npc2 :   i18n_create_ref_message  (  \"my_struct.npc2\"  ,   \"dialog.npc_2\"  , {\n           name : player_name,\n           item :   \"item.map\"                 // using dictionary for \"item.map\"\n       })                                    // `en` : \"Is it your first time here, John? Let me show you around. Here's a Village Map for you.\"\n   };\n   \n   global.npc3   =   i18n_create_ref_message  (  \"global.npc3\"  ,   \"dialog.npc_3\"  , {\n       plural   :   function  (  val  ) {              // with pluralization            \n           return   (val   >=   3  )   ?   1   :   0  ;        // if `plural_value` is 3 or more, use pluralization form 2 (index 1), otherwise use pluralization form 1 (index 0)\n       },\n       plural_value :   0  ,                     // this will be used to determine the pluralization form\n   \n       item :   \"ticket\"  ,                      // using dictionary for \"ticket\"\n       count :   3  ,\n       suffix :   \"s\"\n   });                                       // `en` : \"You need at least 3 tickets to enter the cave.\" (if `plural_value` is lower than 3)\n                                           // `en` : \"Spend {plural_value} tickets to enter the cave?\" (if `plural_value` is 3 or more, interpolation will be used)\n   \n   global.gb_struct   =   {\n       // using linked message\n       npc4 :   i18n_create_ref_message  (  \"g.gb_struct.npc4\"  ,   \"dialog.npc_4\"  , {\n           child : {                         // data for the child message\n               sp_item :   \"apple_box\"         // using dictionary for \"apple_box\"\n           }                                 // `en` : \"My brother was trapped in the cave. I need to find him. Can you help me? I'll reward you with a box of apples if you can find him.\"\n       }),\n   \n       arr : [\n           // a direct example to distinguish between normal named data and dictionary\n           // see the `item` placeholder in the message\n           i18n_create_ref_message  (  \"global.gb_struct.arr.0\"  ,   \"dialog.npc_6\"  , {\n               item :   \"Will of the Adventurer\"       // using dictionary for \"Will of the Adventurer\"\n           })                                        // `en` : \"Take this \"Will of the Adventurer\" skill book. It's A skill that increases the user's attack power by 10% for 30 seconds.\"\n       ]\n   }\n     {\n       \"greet\"  :   \"Hello, {name}!\"  ,\n       \"ask\"  :   \"Do you want this {item}?\"  ,\n       \"ask_2\"  :   \"Do you want this ${item}?\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Please ask ${chief_name} for help.\"  ,\n           \"npc_2\"  :   \"Is it your first time here, {name}? Let me show you around. Here's a ${item} for you.\"  ,\n           \"npc_3\"  :   \"You need at least {count} ${item}{suffix} to enter the cave. | Spend {plural_value} ${item}{suffix} to enter the cave?\"  ,\n           \"npc_4\"  :   \"My brother was trapped in the cave. I need to find him. Can you help me? [[dialog.npc_5]]\"  ,\n           \"npc_5\"  :   \"I'll reward you with a ${sp_item} if you can find him.\"  ,\n           \"npc_6\"  :   \"Take this   \\\"  {item}  \\\"   skill book. It's ${item}.\"\n       }\n   }\n     {\n       \"greet\"  :   \"Halo, {name}!\"  ,\n       \"ask\"  :   \"Apakah kamu ingin {item} ini?\"  ,\n       \"ask_2\"  :   \"Apakah kamu ingin ${item} ini?\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"Harap tanyakan bantuan kepada ${chief_name}.\"  ,\n           \"npc_2\"  :   \"Ini pertama kalinya kamu di sini, {name}? Mari saya tunjukkan sekeliling. Ini ${item} untukmu.\"  ,\n           \"npc_3\"  :   \"Kamu butuh setidaknya {count} ${item} untuk masuk ke gua. | Habiskan {plural_value} ${item} untuk masuk ke gua?\"  ,\n           \"npc_4\"  :   \"Saudaraku terjebak di dalam gua. Aku perlu menemukannya. Bisakah kamu membantuku? [[dialog.npc_5]]\"  ,\n           \"npc_5\"  :   \"Aku akan memberimu ${sp_item} jika kamu bisa menemukannya.\"  ,\n           \"npc_6\"  :   \"Ambil buku keterampilan   \\\"  {item}  \\\"   ini. Ini ${item}.\"\n       }\n   }\n     {\n       \"greet\"  :   \"こんにちは、{name}さん！\"  ,\n       \"ask\"  :   \"この{item}が欲しいですか？\"  ,\n       \"ask_2\"  :   \"この${item}が欲しいですか？\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"${chief_name}さんに助けを求めてください。\"  ,\n           \"npc_2\"  :   \"{name}さん、初めてここに来たのですか？周りを案内しましょう。これはあなたへの${item}です。\"  ,\n           \"npc_3\"  :   \"洞窟に入るには少なくとも{count}個の${item}が必要です。| 洞窟に入るために{plural_value}個の${item}を使いますか？\"  ,\n           \"npc_4\"  :   \"私の兄が洞窟に閉じ込められています。彼を見つける手伝いをしてくれませんか？[[dialog.npc_5]]\"  ,\n           \"npc_5\"  :   \"${sp_item}を見つけたら報酬をあげますよ。\"  ,\n           \"npc_6\"  :   \"  \\\"  {item}  \\\"  スキルブックを受け取ってください。これは${item}です。\"\n       }\n   }\n   You can use the    i18n_get_messages()  or    i18n_create_ref_message()  function to get a message or create a message reference with the   data  that contains the dictionary value. The system will automatically use the dictionary value if it exists, or the data value as is if it doesn't.       As you can see in the example above, the   value  of the passed   data  become the key of the dictionary, and the   key  of the message is used as the value of the dictionary. For example, the   item  data in the   ask_2  message has the value of   apple , which is registered in the   id  locale dictionary as   apel . So, the system will use the   apel  value instead of   apple  when rendering the message.   You   can't  use dictionaries in an   indexed data interpolation , like   {0} ,   {1} , etc. Dictionaries only work with   named data interpolation , like   {item}  or   {name} .       The dictionaries are used   only  if you use the   $  prefix on the   data  name in the message or message reference. If you don't use the   $  prefix, the system will use the data value as is, without checking the dictionaries.       If you use the   $  prefix, but the value is not registered in the dictionaries, the system will use the   data  value as is.        It's a good practice to use dictionaries for   any data  that you want to translate, especially for items, skills, and other game-related terms. This way, you can easily manage the translations and make sure they are   consistent  across your game.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":149,"path":150,"dir":132,"title":151,"description":152,"keywords":153,"body":156},"content:v1:4.advanced:3.optimizations.md","/v1/advanced/optimizations","Optimizations","GM-I18n aims to become a performance-oriented i18n system, and as such, it provides several optimizations to ensure that your game runs smoothly even with extensive localization.",[154,155],"Automatic","Manual","  Optimizations   GM-I18n  aims to become a performance-oriented i18n system, and as such, it provides several optimizations to ensure that your game runs smoothly even with extensive localization.  Automatic  Some optimizations are applied automatically by the system, so you don't have to worry about them. These optimizations include:  Flattened Message Keys  When you're adding message data to the system,   GM-I18n  always flattens the keys   automatically . This means that if you have a message with a nested structure, it will be stored in a flat format, which can significantly speed up lookups and reduce memory usage.  For example, if you have a message like this in   en.json  locale file:     {\n       \"greeting\"  : {\n           \"morning\"  :   \"Good morning!\"  ,\n           \"evening\"  :   \"Good evening!\"\n       }\n   }\n  It will be stored as:     {\n       \"greeting.morning\"  :   \"Good morning!\"  ,\n       \"greeting.evening\"  :   \"Good evening!\"\n   }\n  The messages you add using   i18n_add_messages  function also follow this flattened structure. So, if you add a message like this:     // assume you've  already initialized the i18n system\n   \n   i18n_add_messages  (  \"en\"  , {\n       greeting : {\n           morning:   \"Good morning!\"  ,\n           evening:   \"Good evening!\"\n       }\n   });\n   \n   // will be stored as:\n   // greeting.morning: \"Good morning!\",\n   // greeting.evening: \"Good evening!\"\n   This flattening process is done   automatically  by the system, so you don't need to worry about it when adding messages. You can continue to use nested structures in your code, and the system will handle the conversion for you.   Hashed Message Keys  To further optimize performance, you can enable hashed message keys. This feature allows the system to use a hash of the message key instead of the full key string, which can significantly speed up lookups, especially in large projects with many messages.  To enable hashed message keys, you can set   hashed: true  option in the    i18n_create  function when initializing the i18n system.     // Initialize the i18n system with hashed message keys\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [\n       // array of locales to load\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       // this struct is used to configure the i18n options\n       hashed:   true              // enable hashed message keys\n   });\n   By default, hashed message keys are   enabled . You can disable it by setting   hashed: false  in the    i18n_create  function if you want to.   Optimized Reference Update  If you're using the    i18n_create_ref_message()  function to create references to messages, you're actually optimizing the way you manage messages in your game. Because the   GM-I18n  system will only update all of the references in one go with    i18n_update_refs()  or    i18n_set_locale()  function, instead of updating each reference individually (or even worse, updating the message/reference individually every step in the game loop).  This means that if you change a message, you can simply call    i18n_update_refs()  or    i18n_set_locale()  to update all references at once, rather than having to update each reference individually. This can significantly reduce the overhead of updating messages in your game, especially if you have a lot of references in your code.  Moreover, if the reference you created using    i18n_create_ref_message()  or    i18n_create_ref_asset()  is not used anymore, the system will automatically remove it from the list of references, so you don't have to worry about memory leaks or performance issues caused by unused references.   This optimization is particularly useful in games with dynamic content, where messages may change frequently. By using references and updating them in bulk, you can ensure that your game remains responsive and efficient.       You don't need to worry about the performance impact of updating messages, as the system is designed to handle this efficiently.       The   i18n_create_ref_*  functions are the recommended way to create references to messages and assets in   GM-I18n . They are designed to be efficient and easy to use, allowing you to manage your localization data effectively without sacrificing performance.   Chunk Loading  Let's say you have a large number of locale files to load, such as   langs/en.json ,   langs/id.json , and   langs/ja.json  files, which contain a lot of messages. If you load them all at once, it can cause a performance issue, especially if the files are large or if you have many locales.  Fortunately,   GM-I18n  provides a way to load locale files in chunks, which can help reduce the performance impact of loading large locale files. You can do this by using the   time  option when initializing the i18n system with    i18n_create()  function.  This option allows you to specify an   interval  in   seconds  between loading each locale. Look at the following example:     // Initialize the i18n system without chunk loading\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [                                  // the `time` option is not set\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),                  // so all locale files (langs/en.json, langs/id.json, langs/ja.json) will be loaded at once after 1 step of the game\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),            // it's the same if you set `time: 0`\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )                     // may cause a performance issue if you have a lot of messages in these locale files, or you have a lot of locales to load\n   ]);\n   \n   \n   // Initialize the i18n system with chunk loading\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [                                  // the `time` option is set to 0.5 seconds\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),                  // so the locales will be loaded in chunks, with 0.5 seconds interval between each locale\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       time:   0.5             // load each locale in chunks with 0.5 seconds interval\n   });                       // 0.5 seconds -> load langs/en.json -> 0.5 seconds -> load langs/id.json -> 0.5 seconds -> load langs/ja.json\n  The example above shows how to initialize the i18n system with and without chunk loading. When you set the   time  option, the system will load each locale file in chunks.  You can do more with chunk loading, such as splitting a large locale file into multiple chunks, so that each chunk can be loaded in a separate step. Look  at the following example:      // you can split the locale files into multiple chunks\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  , [  \"~/langs/en1.json\"  ,   \"~/langs/en2.json\"  ]),            // the splitted files will be loaded in chunks, with 0.5 seconds interval between each chunk\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),                             // it's useful if you have a lot of messages in the locale\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       time:   0.5             // load each locale in chunks with 0.5 seconds interval\n   });                       // 0.5 sec -> load langs/en1.json -> 0.5 sec -> load langs/en2.json -> 0.5 sec -> load langs/id.json -> 0.5 sec -> load langs/ja.json\n   \n   \n   // you can also control how the chunks are loaded\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  , [  \"~/langs/en1.json\"  ,   \"~/langs/en2.json\"  ]),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       time: [  0.2  ,   0.2  ,   0.5  ,   1  ]          // set individual loading times for each locale\n   });                                   // 0.2 sec -> load langs/en1.json -> 0.2 sec -> load langs/en2.json -> 0.5 sec -> load langs/id.json -> 1 sec -> load langs/ja.json\n   \n   \n   // use 0 value in the time array to load the locale file after 1 step of the game\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  , [  \"~/langs/en1.json\"  ,   \"~/langs/en2.json\"  ]),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       time: [  0  ,   0  ,   0.5  ,   0.5  ]            // set individual loading times for each locale\n   });                                   // 1 step -> load langs/en1.json -> 1 step -> load langs/en2.json -> 0.5 sec -> load langs/id.json -> 0.5 sec -> load langs/ja.json\n   \n   \n   // the 0 value in the time array is special\n   // it will be shifted to the front of the array, so that the locale file will be loaded first\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  , [  \"~/langs/en1.json\"  ,   \"~/langs/en2.json\"  ]),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       time: [  0  ,   0.2  ,   0  ,   0.3  ]            // set individual loading times for each locale\n   });                                   // 1 step -> load langs/en1.json -> 1 step -> load langs/id.json -> 0.2 sec -> load langs/en2.json -> 0.3 sec -> load langs/ja.json\n     {\n       \"greeting\"  :   \"Hello\"  ,\n       \"farewell\"  :   \"Goodbye\"\n   }\n     {\n       \"welcome\"  :   \"Welcome to our game!\"  ,\n       \"thank_you\"  :   \"Thank you for playing!\"\n   }\n     {\n       \"greeting\"  :   \"Halo\"  ,\n       \"farewell\"  :   \"Selamat tinggal\"  ,\n       \"welcome\"  :   \"Selamat datang di permainan kami!\"  ,\n       \"thank_you\"  :   \"Terima kasih telah bermain!\"\n   }\n     {\n       \"greeting\"  :   \"こんにちは\"  ,\n       \"farewell\"  :   \"さようなら\"  ,\n       \"welcome\"  :   \"私たちのゲームへようこそ！\"  ,\n       \"thank_you\"  :   \"プレイしてくれてありがとう！\"\n   }\n   As you can see, the chunks will be loaded in the order they are defined in the    I18nLocaleInit  array, and the   time  option will control how long it takes to load each chunk.       You can use   0  value in the   time  array to load the locale file after 1 step of the game, which can be useful if you want to load the locale file with important messages first, and then load the rest of the messages in chunks.   Though you can use the   time  option to control how the chunks are loaded, you should be careful not to set the interval too low, as it can cause performance issues if the locale files are large or if you have many locales to load.       You should also avoid setting the interval to   0  for all locales, as it won't have any effect and will cause all locale files to be loaded at once after 1 step of the game.       Beware that the   0  value in the   time  array   won't be loaded immediately . So, if you get a message or creating a message reference before the locale file is loaded, it will return a string in   default_message  option (default is an empty string). You need to hardcode the message if you want to use it before the locale file is loaded. Please read the   System Flow  for more information about how the locale files are loaded.   Message Caching   GM-I18n  also provides a way to cache the messages, so that the system doesn't need to lookup the message from the locale data every time you get the message. You can enable the message caching by setting   cached: true  in the    i18n_create()  function.      // Initialize the i18n system with message caching\n   global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       cached:   true              // enable message caching\n   });\n     {\n       \"greeting\"  :   \"Hello\"  ,\n       \"farewell\"  :   \"Goodbye\"\n   }\n     {\n       \"greeting\"  :   \"Halo\"  ,\n       \"farewell\"  :   \"Selamat tinggal\"\n   }\n     {\n       \"greeting\"  :   \"こんにちは\"  ,\n       \"farewell\"  :   \"さようなら\"\n   }\n   By default, message caching is   disabled . If you enable it and cause performance issue or unexpected behavior, you can disable it by setting   cached: false  in the    i18n_create()  function, or just remove the   cached  option.   Message caching isn't available for HTML5 export. If you enable it, the system will automatically disable it.   Other Automatic Optimizations  Don't worry about the other optimizations, I'll take care of them for you as the development of   GM-I18n  continues. The system is designed to be efficient and will automatically apply various optimizations to ensure that your game runs smoothly, even with extensive localization.   Manual  While the automatic optimizations provided by   GM-I18n  are generally sufficient for most projects, there are some additional manual optimizations you can apply to further enhance performance:  Drawing Templates  If you're using the drawing preset feature, you can optimize the way you draw messages by mixing drawing presets with the regular drawings (GameMaker's   draw_*  functions).  Basically, a drawing template is a drawing preset with more abstracted data, which can be used to create multiple drawings with the same structure but different content. This can help reduce the number of individual drawings you need to manage, and can also improve performance by reusing the same drawing settings for multiple messages.  Same as the drawing preset, you can create a drawing template using    i18n_add_drawings()  function, but with simpler data structure. For example, you can create a drawing template like this:      // assume you've already initialized the i18n system\n   \n   // here's some drawing templates\n   // you must include all available locales in the first argument (locale), so that the drawing template can be used in all locales\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ,   \"ja\"  ], [  \"t_button\"  ,   \"t_header\"  ,   \"t_body\"  ], [           // the `t_` prefix is used to indicate that this is a drawing template\n       new   I18nDrawings  (, fa_center, fa_middle, #  000000  ,   0.65  , , , , ,   true  ),          // just fill the parameters that have the same value in all locales\n       new   I18nDrawings  (, fa_left, fa_middle, #  FFFFFF  ,   0.65  , , , , ,   true  ),            // and skip the parameters that have different values in each locale\n       new   I18nDrawings  (, fa_left, fa_top, #  CCCCCC  ,   0.49  ,   0  ,   1  ,   -  1  ,   1198  ,   true  )\n   ]);\n   \n   // or if you want more control over the drawing templates, you can use this approach\n   // don't forget the `true` value in the last argument\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ,   \"ja\"  ], [  \"center_mid\"  ,   \"left_mid\"  ,   \"left_top\"  ], [\n       new   I18nDrawings  (, fa_center, fa_middle, , , , , , ,   true  ),                       // useful for set the text alignment easily\n       new   I18nDrawings  (, fa_left, fa_middle, , , , , , ,   true  ),\n       new   I18nDrawings  (, fa_left, fa_top, , , , , , ,   true  )\n   ]);\n   \n   // then you can add the missing parameters in previous drawing templates, such as font\n   // this missing parameters will be used as the dynamic data for the drawing template\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ],   \"font1\"  ,              // create `font1` drawing preset to be used in \"en\" and \"id\" locales\n       new   I18nDrawings  (fnNotoSans, , , , , , , , ,   true  )\n   );\n   i18n_add_drawings  ([  \"ja\"  ],   \"font1\"  ,                    // create `font1` drawing preset to be used in \"ja\" locale\n       new   I18nDrawings  (global.font_ja, , , , , , , , ,   true  )\n   );\n   \n   // create some messages that will be drawn\n   my_msg   =   i18n_get_messages  (  \"desc\"  , ,   \"en\"  );                  // \"This is a description of the game.\" static message in en\n   \n   my_msg_ref   =   i18n_create_ref_message  (  \"my_msg_ref\"  ,   \"header\"  , [\n       \"John\"                                                   // this is a dynamic message with indexed data, will be used in the drawing template\n   ]);\n   \n   // and later you can mix the drawing templates with the regular drawings\n   // see the Draw/Draw GUI Event example for more details\n     // a simple example of how to use the drawing templates\n   \n   // set your dynamic valued data using built-in `draw_set_*` functions\n   draw_set_font  (  i18n_get_drawings_data  (  \"font1\"  ,   I18N_DRAWING  .  FONT  ));        // set the dynamic font using `font1` drawing preset\n   i18n_draw_message  (  100  ,   50  ,   \"@:title\"  , ,   \"t_header\"  );                      // \"Game Title\" in en.json, \"Judul Permainan\" in id.json, \"ゲームタイトル\" in ja.json\n   \n   // you may won't notice the difference between drawing preset and drawing template based on the previous example\n   // now let's try to use the drawing template again\n   i18n_use_drawing  (  \"center_mid\"  );                                           // set the text alignment using `center_mid` drawing template\n   draw_set_font  (  i18n_get_drawings_data  (  \"font1\"  ,   I18N_DRAWING  .  FONT  ));        // set the dynamic font using `font1` drawing preset\n   draw_text  (  100  ,   200  , my_msg);                                              // draw the static message \"This is a description of the game.\" \n   draw_text_transformed  (  100  ,   50  , my_msg_ref,   0.65  ,   0.65  ,   0  );                // draw the dynamic message \"Welcome to the Game, John!\"\n     {\n       \"title\"  :   \"Game Title\"  ,\n       \"button\"  :   \"Click Me\"  ,\n       \"header\"  :   \"Welcome to the Game, {0}!\"  ,\n       \"desc\"  :   \"This is a description of the game.\"\n   }\n     {\n       \"title\"  :   \"Judul Permainan\"  ,\n       \"button\"  :   \"Klik Saya\"  ,\n       \"header\"  :   \"Selamat Datang di Permainan, {0}!\"  ,\n       \"desc\"  :   \"Ini adalah deskripsi permainan.\"\n   }\n     {\n       \"title\"  :   \"ゲームタイトル\"  ,\n       \"button\"  :   \"クリックしてください\"  ,\n       \"header\"  :   \"ゲームへようこそ、{0}さん！\"  ,\n       \"desc\"  :   \"これはゲームの説明です。\"\n   }\n   As you can see in the example above, the drawing template is just a mix-and-match of drawing preset with built-in   draw_set_*  functions. This one will help you to create a more complex drawing structure with better performance than using   i18n_draw_message()  function.       For more information about the drawing, please read the   Direct Drawings  section. It may help you to understand how to use drawing templates in your game.        With these optimizations, the   GM-I18n  system should be able to handle large projects with extensive localization without sacrificing performance.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":158,"path":159,"dir":132,"title":160,"description":161,"keywords":162,"body":164},"content:v1:4.advanced:4.customizing.md","/v1/advanced/customizing","Customizing","You can customize the GM-I18n system to fit your needs. In this section, we will discuss about the available customization options.",[163,98,92],"Default Message","  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.     // using i18n_create()\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ], {\n       default_message:   \"Missing Translation\"            // default message for message fallback (default = empty string)\n   });\n   \n   // using i18n_set_default_message()\n   i18n_set_default_message  (  \"Missing Translation\"  );\n   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.     // using i18n_create()\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ], {\n       plural_start_at:   1             // the first plural form is at index 1 (default = 0)\n   });\n  Delimiter  You can change the delimiter (default:   | ) by setting the   plural_delimiter  key in the    i18n_create()  function.     // using i18n_create()\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ], {\n       plural_delimiter:   \"||\"         // the delimiter is now \"||\" (default = \"|\")\n   });\n   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     // using i18n_create()\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ], {\n       linked_start:   \"\u003C\"  ,            // the opening character is now \"\u003C\u003C\" (default = \"[\")\n       linked_end:   \">\"               // the closing character is now \">>\" (default = \"]\")\n   });\n   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   \u003C\u003C  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   \u003C  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   \u003C\u003C  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 (  \u003C\u003Ckey1>> ).        Change these customization options to fit your needs!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":166,"path":167,"dir":168,"title":169,"description":170,"keywords":171,"body":174},"content:v1:5.api-reference:1.global-variables.md","/v1/api-reference/global-variables","api-reference","Global Variables","GM-I18n system uses several global variables to manage localization and internationalization. These variables are essential for accessing localized messages, assets, and other related functionalities.",[172,173],"i18n_name","[i18n_name]","  Global Variables   GM-I18n  system uses several global variables to manage localization and internationalization. These variables are essential for accessing localized messages, assets, and other related functionalities.    Don't modify these variables directly . They are intended for internal use by the i18n system and may lead to unexpected behavior if modified.   i18n_name  The   i18n_name  variable is a global string that holds the name of the initialized i18n system in global scope.    global.i18n_name: String     global.i18n_name   =   \"\"  ;      // once you initialize the i18n system using `i18n_create()`, this variable will be set to the name you provided.\n   [i18n_name]  The   [i18n_name]  variable is a global reference to the i18n system initialized with the name specified in    i18n_create() . It allows you to access the i18n system using the name directly.    global.[i18n_name]: I18n     global.i18n   =   i18n_create  (  \"g.i18n\"  ,   \"en\"  , [                           // the first parameter is the name of the i18n system\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),           // its must be same as the global variable you declared to hold the i18n system\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  )      // you can use \"g.\" shorthand to refer to the global variable\n   ]);\n   \n   global.i18n_name   =   \"i18n\"  ;                // his will be set automatically to the name of the i18n system\n   \n   // example if you want to use other name\n   global.localization   =   i18n_create  (  \"global.localization\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bhs Indonesia\"  ,   \"~/langs/id.json\"  )\n   ]);\n   \n   global.i18n_name   =   \"localization\"  ;        // this will be set automatically to the name of the i18n system\n    You don't need to understand this section in detail, except if you want to extend the i18n system or create your own custom i18n system.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":176,"path":177,"dir":168,"title":178,"description":179,"keywords":180,"body":184},"content:v1:5.api-reference:2.constants.md","/v1/api-reference/constants","Constants","Some constants can help you to work with the GM-I18n API. They are used to define specific behaviors or properties of the API.",[181,182,183],"I18N_DRAWING","I18N_DRAW_TEXT","I18N_REF","  Constants  Some constants can help you to work with the   GM-I18n  API. They are used to define specific behaviors or properties of the API.   I18N_DRAWING  The   I18N_DRAWING  constant is used to define the type of drawing preset member in the    I18nDrawings  struct.  Values     enum   I18N_DRAWING   {\n       FONT  ,\n       HALIGN  ,\n       VALIGN  ,\n       COLOR  ,\n       SCALE  ,\n       ROTATION  ,\n       ALPHA  ,\n       SEP  ,\n       WIDTH\n   }\n  Used By     i18n_get_drawings_data()  Examples     // assume the system is initialized on global variable\n   // assume you have added the \"header\", \"body\", and \"button\" drawing presets\n   \n   // get the font asset from \"header\" drawing preset in \"en\" locale (static)\n   var   font   =   i18n_get_drawings_data  (  \"header\"  ,   I18N_DRAWING  .  FONT  ,   \"en\"  );\n   \n   // get the text separation from \"body\" drawing preset in current locale (dynamic)\n   var   sep   =   i18n_get_drawings_data  (  \"body\"  ,   I18N_DRAWING  .  SEP  );\n   I18N_DRAW_TEXT   Internal    The   I18N_DRAW_TEXT  constant is used to define the type of    draw_text_*  function used by the    i18n_draw_message()  function.  Values     enum   I18N_DRAW_TEXT   {\n       NORMAL  ,\n       EXTENDED  ,\n       COLORED  ,\n       TRANSFORMED  ,\n       EXT_COLORED  ,\n       EXT_TRANSFORMED  ,\n       TRANSFORMED_COLORED  ,\n       EXT_TRANSFORMED_COLORED\n   }\n  Used By     I18nDrawings    Internal      i18n_draw_message()    This constant is used internally by the     i18n_draw_message()    function. You don't need to use it directly.   I18N_REF  The   I18N_REF  constant is used to define the type of reference created by the    i18n_create_ref_message()  and    i18n_create_ref_asset()  functions.  Values     enum   I18N_REF   {\n       ALL  ,\n       MESSAGES  ,\n       ASSETS\n   }\n  Used By     i18n_update_refs()  Examples     // update the references without changing the locale\n   i18n_update_refs  (  I18N_REF  .  ALL  );               // update all references (message and asset)\n   i18n_update_refs  (  I18N_REF  .  MESSAGES  );          // update only message references\n   i18n_update_refs  (  I18N_REF  .  ASSETS  );            // update only asset references\n        You may rarely use these constants, but it's good to know them!  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":186,"path":187,"dir":168,"title":188,"description":189,"keywords":190,"body":194},"content:v1:5.api-reference:3.constructors.md","/v1/api-reference/constructors","Constructors","Constructors are used to create new instances of a struct. They are used to initialize the struct with the required data.",[191,192,193],"I18nLocaleInit","I18nLoad","I18nDrawings","  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      new   I18nLocaleInit  (lang_code, lang_name, [lang_file]);\n     function   I18nLocaleInit  (\n       lang_code  :   string  ,\n       lang_name  :   string  ,\n       lang_file  ?:   string   |   string  []         // default = \"\"\n   )  :   I18nLocaleInit\n     type   I18nLocaleInit   =   {\n       code  :   string  ;\n       name  :   string  ;\n       file  ?:   string   |   string  [];\n   }\n  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     // initialize the GM-I18n system\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ]);\n   \n   // initialize the GM-I18n system with multiple files for a single locale\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  , [  \"~/langs/en1.json\"  ,   \"~/langs/en2.json\"  ]),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Indonesian\"  ,   \"~/langs/id.json\"  )\n   ]);\n   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      new   I18nLoad  (interval, [i18n]);\n     function   I18nLoad  (\n       interval  :   number   |   number  [],\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   I18nLoad\n     type   I18nLoad   =   {\n       i18n  :   I18n  ;\n       files  :   string  [];\n       files_locale  :   string  [];\n       max_step  :   number  ;                 // integer\n       step  :   number  ;                     // integer\n       step_index  :   number  ;               // integer\n       step_time  :   number  [];              // integer[]\n       time  :   number   |   number  [];\n       dt  :   ()   =>   number  ;\n       update  :   (\n           use_delta_time  ?:   boolean      // default = false\n       )   =>   void  ;\n       load  :   (\n           filename  :   string  , \n           locale  :   string\n       )   =>   void  ;\n       flatten  :   (\n           struct  :   { \n               [  key  :   string  ]  :   string   \n           }, \n           i18n  :   I18n  , \n           locale  ?:   string  ,              // default = \"\"\n           prefix  ?:   string               // default = \"\"\n       )   =>   void  ;\n   }\n  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      new   I18nDrawings  ([draw_font], [draw_halign], [draw_valign], [draw_color], [draw_scale], [draw_rotation], [draw_alpha], [text_sep], [text_width]);\n     function   I18nDrawings  (\n       draw_font  ?:   Font  ,\n       draw_halign  ?:   fa_left   |   fa_center   |   fa_right  ,\n       draw_valign  ?:   fa_top   |   fa_middle   |   fa_bottom  ,\n       draw_color  ?:   number   |   number  [],       // color constants, or color gradient [c1, c2, c3, c4]\n       draw_scale  ?:   number  ,\n       draw_rotation  ?:   number  ,\n       draw_alpha  ?:   number  ,                  // 0 - 1\n       text_sep  ?:   number  ,                    // default = -1\n       text_width  ?:   number                   // default = room_width\n   )  :   I18nDrawings\n     type   I18nDrawings   =   {\n       alpha  ?:   number  ;                       // 0 - 1\n       color  ?:   number   |   number  [];            // color constants, or color gradient [c1, c2, c3, c4]\n       draw_type  :   I18N_DRAW_TEXT  ;\n       font  ?:   Font  ;\n       halign  ?:   fa_left   |   fa_center   |   fa_right  ;\n       rotation  ?:   number  ;\n       scale  ?:   number  ;\n       sep  :   number  ;                          // default = -1\n       valign  ?:   fa_top   |   fa_middle   |   fa_bottom  ;\n       width  :   number  ;                         // default = room_width\n   }\n  Parameters     Name  Type  Default  Description    draw_font  Font Asset | String   undefined  The font to use in   draw_set_font()  function. If a string is provided, it will be converted to an asset index.   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.   is_template  Boolean   false  Whether the drawing preset is a template or not.  Returns    I18nDrawings  Examples      // only for explanation purpose, DON'T copy-paste this code\n   // title\n   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  );\n   \n   // header\n   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  );\n   \n   // body\n   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   32  ,   700  );\n   \n   // with other font\n   I18nDrawings  (fnRoboto, fa_right, fa_bottom, #  999999  ,   0.7  ,   0  ,   1  ,   -  1  ,   700  );\n   \n   // font asset created from code\n   I18nDrawings  (global.font_ja, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  );\n     // assume the system is initialized on global variable\n   // focus only on the I18nDrawings constructor\n   \n   // standard\n   i18n_add_drawings  (  \"en\"  ,   \"title\"  , \n       new   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  )\n   );\n   \n   // completed\n   i18n_add_drawings  (  \"en\"  ,   \"header\"  , \n       new   I18nDrawings  (fnRoboto, fa_right, fa_bottom, #  999999  ,   0.7  ,   0  ,   1  ,   -  1  ,   700  )\n   );\n   \n   // skip some parameters\n   i18n_add_drawings  (  \"ja\"  ,   \"header\"  , \n       new   I18nDrawings  (global.font_ja, , , #  FFFFFF  )\n   );\n   \n   i18n_add_drawings  (  \"ja\"  ,   \"body\"  , \n       new   I18nDrawings  (, , , ,   0.8  ,   0  ,   1  ,   32  ,   700  )\n   );\n   You can skip any parameters you don't want to use. The missing parameters will be ignored when used in    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.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":196,"path":197,"dir":198,"title":199,"description":200,"keywords":201,"body":206},"content:v1:5.api-reference:4.functions:binary-search.md","/v1/api-reference/functions/binary-search","functions","binary_search()","This function is used to search for a value in a sorted array using binary search algorithm. It's a helper function used internally by the GM-I18n system. You can also use it on your own code if you need to search for a value in a sorted array, not only exclusively for the GM-I18n system.",[202,203,204,205],"Syntax","Parameters","Returns","Examples","  binary_search()  This function is used to search for a value in a sorted array using binary search algorithm. It's a helper function used internally by the   GM-I18n  system. You can also use it on your own code if you need to search for a value in a sorted array, not only exclusively for the   GM-I18n  system.  Syntax      binary_search  (array, target);\n     function   binary_search  (\n       array  :   any  [],\n       target  :   any\n   )  :   number\n  Parameters     Name  Type  Default  Description    array  Array   The sorted array to search for the target value.   target  Any   The target value to search for in the array.  Returns    Integer  (the index of the target value in the array, or   -1  if not found)  Examples     // create a sorted array\n   var   arr   =   [  1  ,   2  ,   3  ,   4  ,   5  ,   6  ,   7  ,   8  ,   9  ,   10  ];\n   \n   // search for the index of number 5 in the array\n   var   index   =   binary_search  (arr,   5  );       // 4 (index of number 5 in the array)\n   \n   // search for the index of number 11 in the array\n   var   index   =   binary_search  (arr,   11  );      // -1 (not found)\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":208,"path":209,"dir":198,"title":210,"description":211,"keywords":212,"body":213},"content:v1:5.api-reference:4.functions:binary-search-insert-pos.md","/v1/api-reference/functions/binary-search-insert-pos","binary_search_insert_pos()","This function is used to find the correct insertion position for a value in a sorted array using binary search algorithm. It's a helper function used internally by the GM-I18n system. You can also use it on your own code if you need to find the insertion position for a value in a sorted array, not only exclusively for the GM-I18n system.",[202,203,204,205],"  binary_search_insert_pos()  This function is used to find the correct insertion position for a value in a sorted array using binary search algorithm. It's a helper function used internally by the   GM-I18n  system. You can also use it on your own code if you need to find the insertion position for a value in a sorted array, not only exclusively for the   GM-I18n  system.  Syntax      binary_search_insert_pos  (array, target);\n     function   binary_search_insert_pos  (\n       array  :   any  [],\n       target  :   any\n   )  :   number\n  Parameters     Name  Type  Default  Description    array  Array   The sorted array to find the insertion position for the target value.   target  Any   The target value to find the insertion position for in the array.  Returns    Integer  (the insertion position for the target value in the array)  Examples     // create a sorted array\n   var   arr   =   [  1  ,   2  ,   3  ,   4  ,   5  ,   6  ,   7  ,   8  ,   9  ,   10  ];\n   \n   // find the insertion position for number 5 in the array\n   var   index   =   binary_search_insert_pos  (arr,   5  );       // 4 (index of number 5 in the array)\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":215,"path":216,"dir":198,"title":217,"description":218,"keywords":219,"body":220},"content:v1:5.api-reference:4.functions:i18n-add-dictionaries.md","/v1/api-reference/functions/i18n-add-dictionaries","i18n_add_dictionaries()","The i18n_add_dictionaries() function is used to add dictionaries to the specified locale.",[202,203,204,205],"  i18n_add_dictionaries()  The   i18n_add_dictionaries()  function is used to add dictionaries to the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_add_dictionaries  (locale, data, [i18n]);\n     function   i18n_add_dictionaries  (\n       locale  :   string  ,\n       data  :   [  string  ,   string  ]   |   [  string  ,   string  ][],      // [key, value] or [[key1, value1], [key2, value2], ...]\n       i18n  ?:   I18n   |   boolean                             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    locale  String   The locale to add the dictionaries to (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.).   data  [String, String] | [String, String][]   The dictionaries to add with [\"key\", value] pair, or array of [\"key\", value] pair (e.g.   [\"apple\", \"apel\"]  or   [[\"apple\", \"apel\"], [\"banana\", \"pisang\"], [\"orange\", \"jeruk\"]] ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // assume the system is initialized on global variable\n   \n   // add \"apple\" -> \"apel\" dictionary to \"id\" locale\n   i18n_add_dictionaries  (  \"id\"  , [  \"apple\"  ,   \"apel\"  ]); \n   \n   // add more dictionaries to \"id\" locale\n   i18n_add_dictionaries  (  \"id\"  , [\n       [  \"banana\"  ,   \"pisang\"  ],\n       [  \"orange\"  ,   \"jeruk\"  ],\n       [  \"one\"  ,   \"satu\"  ],\n       [  \"two\"  ,   \"dua\"  ],\n       [  \"three\"  ,   \"tiga\"  ]\n   ]);\n   \n   // add dictionaries to \"ja\" locale\n   i18n_add_dictionaries  (  \"ja\"  , [\n       [  \"apple\"  ,   \"リンゴ\"  ],\n       [  \"banana\"  ,   \"バナナ\"  ],\n       [  \"orange\"  ,   \"オレンジ\"  ],\n       [  \"one\"  ,   \"一\"  ],\n       [  \"two\"  ,   \"二\"  ],\n       [  \"three\"  ,   \"三\"  ]\n   ]);\n   \n   // you can add number as well\n   i18n_add_dictionaries  (  \"ar\"  , [\n       [  \"1\"  ,   \"١\"  ],\n       [  \"2\"  ,   \"٢\"  ],\n       [  \"3\"  ,   \"٣\"  ],\n       [  \"4\"  ,   \"٤\"  ],\n       [  \"5\"  ,   \"٥\"  ]\n   ]);\n   \n   // you can also add dictionaries for the default locale (en), or variant of it\n   i18n_add_dictionaries  (  \"en_GB\"  , [\n       [  \"soccer\"  ,   \"football\"  ],\n       [  \"cookie\"  ,   \"biscuit\"  ],\n       [  \"fries\"  ,   \"chips\"  ]\n   ])\n   \n   // key-value pair is also supported\n   i18n_add_dictionaries  (  \"en\"  , [\n       [  \"hello\"  ,   \"Hello World!\"  ],\n       [  \"btn.cancel\"  ,   \"Cancel\"  ],\n       [  \"btn.yes\"  ,   \"Yes\"  ],\n       [  \"btn.no\"  ,   \"No\"  ]\n   ]);\n   \n   // you can make it as a glossary-like dictionaries\n   i18n_add_dictionaries  (  \"en\"  , [\n       [  \"Cure\"  ,   \"A beginner skill of a healer that heals a single target.\"  ],\n       [  \"Will of the Adventurer\"  ,   \"A skill that increases the user's attack power by 10% for 30 seconds.\"  ],\n       [  \"Fireball\"  ,   \"A powerful fire spell that deals damage to all enemies in a small area.\"  ],\n       [  \"Potion\"  ,   \"A consumable item that restores 50 HP when used.\"  ],\n       [  \"Elixir\"  ,   \"A consumable item that restores 100 MP when used.\"  ],\n       [  \"Mana Potion\"  ,   \"A consumable item that restores 50 MP when used.\"  ],\n       [  \"Phoenix Down\"  ,   \"An item that revives a fallen ally with 50% HP.\"  ],\n       [  \"Ether\"  ,   \"An item that restores 30 MP to an ally.\"  ]\n   ]);\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":222,"path":223,"dir":198,"title":224,"description":225,"keywords":226,"body":227},"content:v1:5.api-reference:4.functions:i18n-add-drawings.md","/v1/api-reference/functions/i18n-add-drawings","i18n_add_drawings()","The i18n_add_drawings() function is used to add drawing presets to the specified locale(s).",[202,203,204,205],"  i18n_add_drawings()  The   i18n_add_drawings()  function is used to add drawing presets to the specified locale(s).  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_add_drawings  (locale, preset_name, data, [use_ref], [i18n]);\n     function   i18n_add_drawings  (\n       locale  :   string   |   string  [],\n       preset_name  :   string   |   string  [],\n       data  :   I18nDrawings   |   I18nDrawings  [],\n       use_ref  ?:   boolean  ,              // default = true\n       i18n  ?:   I18n   |   boolean           // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    locale  String | String[]   The locale code to add the drawing preset(s) (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). You can pass a string for single locale, or an array of string for multiple locales (e.g.   [\"en\", \"id\", \"ja\"] ).   preset_name  String | String[]   The name of the drawing preset(s) (e.g.   \"header\" ,   \"body\" ,   \"title\" , etc.). You can pass a string for single preset, or an array of string for multiple presets (e.g.   [\"header\", \"body\", \"title\"] ).   data  I18nDrawings | I18nDrawings[]   The drawing preset data. You can pass a single    I18nDrawings  struct for single preset, or an array of    I18nDrawings  struct for multiple presets.   use_ref  Boolean   true  Use the first I18nDrawings struct as a reference, instead of creating a new one. Only works if the   locale  parameter is an array. Recommended to be   true  if you want to use the same drawing preset for multiple locales.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // add \"header\" drawing preset to \"en\" locale\n   i18n_add_drawings  (  \"en\"  ,   \"header\"  , \n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  )\n   );\n   \n   // add \"header\" drawing preset to \"en\" and \"id\" locales\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ],   \"header\"  , [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  )\n   ]);\n   \n   // same, but the \"en\" and \"id\" won't have the same struct reference\n   // only use this if you want to modify the drawing preset for each locale\n   // otherwise, keep the `use_ref` to `true`\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ],   \"header\"  , [\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  )\n   ],   false  );\n   \n   // add \"header\" and \"body\" drawing presets to \"ja\" locale\n   i18n_add_drawings  (  \"ja\"  , [  \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (global.font_ja, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (global.font_ja, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n   \n   // add \"title\", \"header\", and \"body\" drawing presets to \"en\", \"id\", \"my\", and \"fr\" locales\n   // you're recommended to use this method if you want to use the same drawing preset for multiple locales\n   // the drawing presets only created once in \"en\" locale, and the rest of the locale will just reference the \"en\" locale\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ,   \"my\"  ,   \"fr\"  ], [  \"title\"  ,   \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":229,"path":230,"dir":198,"title":231,"description":232,"keywords":233,"body":234},"content:v1:5.api-reference:4.functions:i18n-add-locales.md","/v1/api-reference/functions/i18n-add-locales","i18n_add_locales()","The i18n_add_locales() function is used to add new locales with empty data to the GM-I18n system.",[202,203,204,205],"  i18n_add_locales()  The   i18n_add_locales()  function is used to add new locales with empty data to the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_add_locales  (code, [i18n]);\n     function   i18n_add_locales  (\n       code  :   string   |   string  [],\n       i18n  ?:   I18n   |   boolean           // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    code  String | String[]   The locale code(s) to add (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). You can pass a string for single locale, or an array of string for multiple locales (e.g.   [\"en\", \"id\", \"ja\"] ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // add \"my\" locale to the global i18n struct\n   i18n_add_locales  (  \"my\"  );\n   \n   // add \"my\" and \"fr\" locales to the global i18n struct\n   i18n_add_locales  ([  \"my\"  ,   \"fr\"  ]);\n   \n   // ad \"cn\", \"jp\", and \"kr\" locales to instance-scoped i18n\n   // assume you have created the i18n struct in instance variable\n   i18n_add_locales  ([  \"cn\"  ,   \"jp\"  ,   \"kr\"  ], i18n);\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":236,"path":237,"dir":198,"title":238,"description":239,"keywords":240,"body":241},"content:v1:5.api-reference:4.functions:i18n-add-messages.md","/v1/api-reference/functions/i18n-add-messages","i18n_add_messages()","The i18n_add_messages() function is used to add messages to the specified locale.",[202,203,204,205],"  i18n_add_messages()  The   i18n_add_messages()  function is used to add messages to the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_add_messages  (locale, data, [i18n]);\n     function   i18n_add_messages  (\n       locale  :   string  ,\n       data  :   { \n           [  key  :   string  ]  :   string  ; \n       },\n       i18n  ?:   I18n   |   boolean           // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    locale  String   The locale to add the messages to (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.).   data  Struct   The messages to add. The   key  is the message key, and the   value  is the message value (e.g.   { hello: \"Hello World!\" } ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // add messages to \"en\" locale\n   i18n_add_messages  (  \"en\"  , {\n       hello:   \"Hello World!\"  ,\n       bye:   \"Goodbye World!\"  ,\n       welcome:   \"Welcome to {0}, {1}!\"  ,\n       dialog: {\n           npc_1:   \"I have {count1} {item1}{suffix1}. Do you want to trade them with my {count2} bamboos, {name}?\"\n       }\n   });\n   \n   // add messages to \"id\" locale\n   i18n_add_messages  (  \"id\"  , {\n       hello:   \"Halo Dunia!\"  ,\n       bye:   \"Selamat Tinggal!\"  ,\n       welcome:   \"Selamat datang di {0}, {1}!\"  ,\n       dialog: {\n           npc_1:   \"Aku punya {count1} {item1}. Mau tukeran sama aku dengan {count2} bambu, {name}?\"\n       }\n   });\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":243,"path":244,"dir":198,"title":245,"description":246,"keywords":247,"body":248},"content:v1:5.api-reference:4.functions:i18n-cache-exists.md","/v1/api-reference/functions/i18n-cache-exists","i18n_cache_exists()","The i18n_cache_exists() function is used to check if the specified cache is already created in the GM-I18n system.",[202,203,204,205],"  i18n_cache_exists()  The   i18n_cache_exists()  function is used to check if the specified cache is already created in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_cache_exists  (cache_id, [i18n]);\n     function   i18n_cache_exists  (\n       cache_id  :   number  ,\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   boolean\n  Parameters     Name  Type  Default  Description    cache_id  Integer   The cache ID to check. You can get it from    i18n_get_cache_id()  function.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Boolean  Examples      // assume the system is initialized on global variable\n   \n   // get the cache ID from \"hello\" key, from \"en\" locale\n   var   cache_id   =   i18n_get_cache_id  (  \"hello\"  , ,   \"en\"  );\n   \n   // check if the cache is already created in the system\n   var   is_cache_exists   =   i18n_cache_exists  (cache_id);\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"\n   }\n    The message caching isn't available for HTML5 export. So, this function will always return   false  in HTML5.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":250,"path":251,"dir":198,"title":252,"description":253,"keywords":254,"body":255},"content:v1:5.api-reference:4.functions:i18n-choose.md","/v1/api-reference/functions/i18n-choose","i18n_choose()","The i18n_choose() function is used to choose the correct message based on the locale code parameter.",[202,203,204,205],"  i18n_choose()  The   i18n_choose()  function is used to choose the correct message based on the locale code parameter.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_choose  (data, [locale], [single_use], [i18n]);\n     function   i18n_choose  (\n       data  :   {\n           [  locale_code  :   string  ]  :   any  ;\n       },\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       single_use  ?:   boolean  ,             // default = false\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   any\n  Parameters     Name  Type  Default  Description    data  Struct   The data to choose from. The   key  is the locale code, and the   value  is the data to return (e.g.   { en: \"Hello World!\", id: \"Halo Dunia!\" } ).   locale  String   \"\"  The locale code to choose the data from. Leave it empty to use the   current locale .   single_use  Boolean   false  If   true , the function will delete the struct after selecting the data.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  I18n struct.  Returns    Any  (the data from the specified locale code)  Examples     // assume the system is initialized on global variable\n   \n   // choose the correct message based on the locale\n   var   msg   =   i18n_choose  ({\n       en:   \"Hello World!\"  ,\n       id:   \"Halo Dunia!\"  ,\n       ja:   \"こんにちは、世界！\"\n   },   \"en\"  );                     // \"Hello World!\"\n   \n   // choose the correct message based on the current locale\n   var   msg   =   i18n_choose  ({\n       en:   \"Hello World!\"  ,\n       id:   \"Halo Dunia!\"  ,\n       ja:   \"こんにちは、世界！\"\n   });                           // \"Hello World!\" (if the current locale is \"en\")\n   \n   // delete the struct after selecting the data\n   var   msg   =   i18n_choose  ({\n       en: sprHelloEn,\n       id: sprHelloId,\n       ja: sprHelloJa\n   }, ,   true  );                   // sprHelloEn sprite (if the current locale is \"en\")\n    The fallback feature is working in this function. So, if you don't set the data for the current locale, it will try to find the data in the fallback locale.   You need to set the default locale code in the   data  parameter. So, if your default locale is   en , you need to set the   en  key in the   data  parameter.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":257,"path":258,"dir":198,"title":259,"description":260,"keywords":261,"body":262},"content:v1:5.api-reference:4.functions:i18n-clear-cache.md","/v1/api-reference/functions/i18n-clear-cache","i18n_clear_cache()","The i18n_clear_cache() function is used to clear the cache in the GM-I18n system.",[202,203,204,205],"  i18n_clear_cache()  The   i18n_clear_cache()  function is used to clear the cache in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_clear_cache  ([i18n]);\n     function   i18n_clear_cache  (\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   \n   // create some caches\n   i18n_create_cache  (  \"hello\"  , ,   \"en\"  );       // \"Hello World!\"\n   \n   i18n_create_cache  (  \"bye\"  , ,   \"en\"  );         // \"Goodbye World!\"\n   \n   i18n_create_cache  (  \"greet\"  , {              // \"Halo, John!\"\n       name:   \"John\"\n   },   \"id\"  );\n     // clear all caches\n   i18n_clear_cache  ();\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"\n   }\n    It's recommended to only clear the cache when you're sure that you won't need the cached message anymore. So, the suitable events to clear the cache are   Clean Up Event ,   Room End Event ,   Game End Event , or other events that you know that the caches won't be used again.       The cache is automatically cleared when the i18n system is destroyed, so you don't have to worry about memory leaks.       The message caching isn't available for HTML5 export. So, this function will do nothing in HTML5.    Don't use this function on events that updated every step (such as   Step Event ,   Draw Event , etc.)! It will cause a performance issue and there's no point to use the message caching feature if you do that.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":264,"path":265,"dir":198,"title":266,"description":267,"keywords":268,"body":269},"content:v1:5.api-reference:4.functions:i18n-clear-messages.md","/v1/api-reference/functions/i18n-clear-messages","i18n_clear_messages()","The i18n_clear_messages() function is used to clear all messages in the specified locale.",[202,203,204,205],"  i18n_clear_messages()  The   i18n_clear_messages()  function is used to clear all messages in the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_clear_messages  (locale, [i18n]);\n     function   i18n_clear_messages  (\n       locale  :   string   |   string  []   |   \"all\"  ,                \n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    locale  String | String[]   The locale code to clear the messages from. Leave it empty to clear the messages from the   current locale . You can pass a string for single locale, or an array of string for multiple locales (e.g.   [\"en\", \"id\", \"ja\"] ). You can also pass   \"all\"  to clear the messages from all locales.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   \n   // clear all messages from \"id\" locale\n   i18n_clear_messages  (  \"id\"  );\n   \n   // clear all messages from the current locale\n   i18n_clear_messages  ();\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":271,"path":272,"dir":198,"title":273,"description":274,"keywords":275,"body":276},"content:v1:5.api-reference:4.functions:i18n-create.md","/v1/api-reference/functions/i18n-create","i18n_create()","The i18n_create() function is used to create a new GM-I18n system. This function will initialize the i18n system and return a struct reference to it.",[202,203,204,205],"  i18n_create()  The   i18n_create()  function is used to create a new   GM-I18n  system. This function will initialize the i18n system and return a struct reference to it.  This is the most important function in the   GM-I18n  API. You must call this function before using any other functions in the API.  Syntax      i18n_create  (var_name, default_locale, locales, [options]);\n     function   i18n_create  (\n       var_name  :   string  ,                             // variable name to store the i18n system\n       default_locale  :   string  ,                       // default/fallback language code\n       locales  :   I18nLocaleInit  [],                    // array of `I18nLocaleInit` struct to initialize the available locales\n       options  ?:   boolean   |   {                         // default = false (no options)\n           cached  ?:   boolean  ;                         // enable message caching, default = false\n           debug  ?:   boolean  ;                          // toggle debug mode, default = false\n           default_message  ?:   string  ;                 // default message, default = \"\"\n           hashed  :   boolean  ;                          // enable hashed message, default = true\n           linked_end  ?:   string  ;                      // linked message end delimiter, default = \"]\"\n           linked_start  ?:   string  ;                    // linked message start delimiter, default = \"[\"\n           plural_delimiter  ?:   string  ;                // plural message delimiter, default = \"|\"\n           plural_start_at  ?:   number  ;                 // plural message starting index, default = 0\n           time  ?:   number   |   number  []   |   boolean  ;       // locale files loading interval, default = false (load all files at once)\n       }\n   )  :   I18n\n     type   I18n   =   {\n       cache  :   {\n           ids  :   integer  [];\n           values  :   string  [];\n           keys  :   string  [];\n           data  :   any  [];\n           locales  :   string  []\n       };\n       cached  :   boolean  ;                      // message caching\n       data  :   {\n           [  locale_code  :   string  ]  :   {\n               dictionaries  :   {\n                   [  key  :   number  ]  :   string  ;                // key = dictionary key (hashed automatically)\n               };\n               drawings  :   {\n                   [  preset_name  :   string  ]  :   I18nDrawings  ;\n               };\n               messages  :   {\n                   [  key  :   string   |   number  ]  :   string  ;       // key = message key\n               };\n           };\n       };\n       debug  :   boolean  ;                       // debug mode\n       default_locale  :   string  ;               // default/fallback language\n       default_message  :   string  ;              // default message\n       drawing_presets  :   I18nDrawings  [];      // drawing presets in all locales (become undefined after all files are loaded and all fonts are converted)\n       hashed  :   boolean  ;                      // enable hashed message\n       linked_end  :   string  ;                   // linked message end delimiter\n       linked_start  :   string  ;                 // linked message start delimiter\n       loader  :   I18nLoad  ;                     // locale files loader (become undefined after all files are loaded)\n       locale  :   string  ;                       // selected/current language\n       locales  :   I18nLocaleInit  [];            // available locales from `locales` parameter\n       name  :   string  ;                         // variable name to store the i18n system\n       plural_delimiter  :   string  ;             // plural message delimiter\n       plural_start_at  :   number  ;              // plural message starting index\n       refs  :   {\n           messages  :   {\n               inst  :   (  Instance   |   \"global\"  )[],\n               refs  :   string  [],\n               keys  :   string  [],\n               data  :   (  number   |   any  []   |   { [  key  :   string  ]  :   any  ; })[],\n           };\n           assets  :   {\n               inst  :   (  Instance   |   \"global\"  )[],\n               refs  :   string  [],\n               assets  :   { [  key  :   string  ]  :   Asset  ; }[]\n           };\n       };\n       scope  :   \"global\"   |   \"instance\"  ;         // scope of the i18n system\n       time  :   number   |   number  []   |   boolean  ;    // locale files loading interval\n   }\n  Parameters     Name  Type  Default  Description    var_name  String   The name of the variable to store the i18n system (e.g.   global.i18n ). Use   global  keyword if you want to store it in global variable.   default_locale  String   The default locale code to use (e.g.   en ,   id ,   ja , etc.).   locales  I18nLocaleInit[]   The array of    I18nLocaleInit  struct to initialize the available locales.   options  Boolean | Struct   false  The options to configure the i18n system. You can pass your desired options as a struct (e.g.   { debug: true, default_message: \"N/A\" } ).  Returns    I18n  Examples     // initialize the GM-I18n system\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bahasa Indonesia\"  ,   \"~/langs/id.json\"  )\n   ]);\n   \n   // initialize the GM-I18n system with options\n   global.i18n   =   i18n_create  (  \"global.i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bahasa Indonesia\"  ,   \"~/langs/id.json\"  ),\n       new   I18nLocaleInit  (  \"ja\"  ,   \"日本語\"  ,   \"~/langs/ja.json\"  )\n   ], {\n       debug:   true  ,\n       default_message:   \"N/A\"  ,\n       hashed:   true  ,\n       plural_start_at:   1  ,\n       time:   0.5\n   });\n   \n   // initialize the GM-I18n system in instance variable (not recommended)\n   i18n   =   i18n_create  (  \"i18n\"  ,   \"en\"  , [\n       new   I18nLocaleInit  (  \"en\"  ,   \"English\"  ,   \"~/langs/en.json\"  ),\n       new   I18nLocaleInit  (  \"id\"  ,   \"Bahasa Indonesia\"  ,   \"~/langs/id.json\"  )\n   ]);\n    The   i18n_create()  function will automatically set the    global.i18n_name  variable to the name of the i18n system you created. You can use this variable to access the i18n system from anywhere in your game.       You can optimize the locale files loading by using the   time  option. Please read the   Chunk Loading  section for more information.   Though you can create multiple   GM-I18n  system, it's not recommended, unless you know what you're doing.   You're   heavily recommended  to use   global  variable to store the i18n system.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":278,"path":279,"dir":198,"title":280,"description":281,"keywords":282,"body":283},"content:v1:5.api-reference:4.functions:i18n-create-cache.md","/v1/api-reference/functions/i18n-create-cache","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.",[202,203,204,205],"  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      i18n_create_cache  (key, [data], [locale], [value], [i18n]);\n     function   i18n_create_cache  (\n       key  :   string  ,\n       data  ?:   number   |   any  []   |   { \n           [  key  :   string  ]  :   any  ; \n       },\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       value  ?:   string  ,                   // default = \"\" (get the message based on the key and data)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  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      // assume the system is initialized on global variable\n   \n   // create a cache for \"hello\" key, from \"en\" locale\n   i18n_create_cache  (  \"hello\"  , ,   \"en\"  );\n   \n   // create a cache for \"bye\" key, from current locale\n   i18n_create_cache  (  \"bye\"  );\n   \n   // create a cache for \"greet\" key, from current locale\n   // using named data interpolation\n   i18n_create_cache  (  \"greet\"  , {\n       name:   \"John\"                      // {name} = \"John\"\n   });\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"\n   }\n    The message caching isn't available for HTML5 export. So, this function will do nothing in HTML5.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":285,"path":286,"dir":198,"title":287,"description":288,"keywords":289,"body":290},"content:v1:5.api-reference:4.functions:i18n-create-ref-asset.md","/v1/api-reference/functions/i18n-create-ref-asset","i18n_create_ref_asset()","The i18n_create_ref_asset() function is used to create a reference to the localized asset. This reference will automatically update itself when the locale is changed by calling i18n_set_locale() function.",[202,203,204,205],"  i18n_create_ref_asset()  The   i18n_create_ref_asset()  function is used to create a reference to the localized asset. This reference will automatically update itself when the locale is changed by calling    i18n_set_locale()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_create_ref_asset  (var_name, locale_asset, [i18n]);\n     function   i18n_create_ref_asset  (\n       var_name  :   string  ,\n       locale_asset  :   { \n           [  locale_code  :   string  ]  :   Asset  ; \n       },\n       i18n  ?:   I18n   |   boolean                             // default = false (using global i18n struct)\n   )  :   Asset\n  Parameters     Name  Type  Default  Description    var_name  String   The name of the variable that will store the asset reference. The   var_name  can be in any level of the instance variable or global variable (e.g.   global.my_obj.my_spr ,   my_obj.my_spr ,   my_arr.0 ,   my_struct.my_spr , etc.).   locale_asset  Struct   The localized asset for each locale. The   key  is the locale code, and the   value  is the asset ID (e.g.   {\"en\": sprSplashEn, \"id\": sprSplashId, \"ja\": sprSplashJa} ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Asset  (in the   current locale  of the   i18n  struct)  Examples      // assume the system is initialized on global variable\n   \n   // create some asset references\n   // the `var_name` is the name of the variable that will store the asset reference\n   // for this example, we will use the `my_spr` variable to store the sprite reference\n   my_spr   =   i18n_create_ref_asset  (  \"my_spr\"  , {\n       en: sprSplashEn,\n       id: sprSplashId,\n       ja: sprSplashJa\n   });\n   \n   // you can create the reference in array\n   // add the index of the array to the `var_name` separated by dot \".\"\n   // so, the `var_name` is \"my_arr.0\"\n   my_arr   =   [\n       i18n_create_ref_asset  (  \"my_arr.0\"  , {\n           en: sndVoiceEn,\n           id: sndVoiceId,\n           ja: sndVoiceJa\n       })\n   ];\n   \n   // you can also create the reference in struct\n   // add the member name of the struct to the `var_name` separated by dot \".\" \n   // so, the `var_name` is \"my_struct.my_spr\" and \"my_struct.my_snd.0\"\n   my_struct   =   {\n       my_spr :   i18n_create_ref_asset  (  \"my_struct.my_spr\"  , {\n           en: sprTutorial1En,\n           id: sprTutorial1Id,\n           ja: sprTutorial1Ja\n       }),\n       my_snd : [\n           i18n_create_ref_asset  (  \"my_struct.my_snd.0\"  , {\n               en: sndVoiceEn,\n               id: sndVoiceId,\n               ja: sndVoiceJa\n           })\n       ]\n   };\n   \n   // in global variable, add \"global.\" or \"g.\" as the prefix\n   global.my_obj   =   i18n_create_ref_asset  (  \"global.my_obj\"  , {\n       en: objPlayerEn,\n       id: objPlayerId,\n       ja: objPlayerJa\n   });\n   \n   // you can also create the reference in array in global variable\n   global.my_room   =   [\n       i18n_create_ref_asset  (  \"g.my_room.0\"  , {\n           en: rmMainMenuEn,\n           id: rmMainMenuId,\n           ja: rmMainMenuJa\n       })\n   ];\n   \n   // you can also create the reference in struct in global variable, and even nested struct in global struct!\n   global.my_font   =   {\n       my_font_1 :   i18n_create_ref_asset  (  \"g.my_font.my_font_1\"  , {\n           en: fnNotoSansEn,\n           id: fnNotoSansId,\n           ja: fnNotoSansJa\n       }),\n       ui_font : [\n           i18n_create_ref_asset  (  \"global.my_font.ui_font.0\"  , {\n               en: fnNotoSansEn,\n               id: fnNotoSansId,\n               ja: fnNotoSansJa\n           })\n       ]\n   };\n     // change the locale, and the assets will be changed automatically!\n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :   i18n_set_locale  (  \"id\"  );   break  ;\n       case   \"id\"  :   i18n_set_locale  (  \"ja\"  );   break  ;\n       case   \"ja\"  :   i18n_set_locale  (  \"en\"  );   break  ;\n   }\n     // play the sound\n   audio_play_sound  (my_arr[  0  ],   1  ,   false  );\n   audio_play_sound  (my_struct.my_snd[  0  ],   1  ,   false  );\n     // draw the sprite\n   draw_sprite  (my_spr,   0  ,   100  ,   50  );\n   draw_sprite_ext  (my_struct.my_spr,   0  ,   100  ,   200  ,   1  ,   1  ,   0  , c_white,   1  );\n    The   var_name  is   not  the name of the asset itself. You can name the   var_name  as you want, as long as it's   unique  (no duplicated name) in the same level of the variable.   You're   heavily recommended  to create any i18n references in the   Create Event .  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":292,"path":293,"dir":198,"title":294,"description":295,"keywords":296,"body":297},"content:v1:5.api-reference:4.functions:i18n-create-ref-message.md","/v1/api-reference/functions/i18n-create-ref-message","i18n_create_ref_message()","The i18n_create_ref_message() function is used to create a reference to the localized message. This reference will automatically update itself when the locale is changed by calling i18n_set_locale() function.",[202,203,204,205],"  i18n_create_ref_message()  The   i18n_create_ref_message()  function is used to create a reference to the localized message. This reference will automatically update itself when the locale is changed by calling    i18n_set_locale()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_create_ref_message  (var_name, key, [data], [i18n]);\n     function   i18n_create_ref_message  (\n       var_name  :   string  ,\n       key  :   string  ,\n       data  ?:   number   |   any  []   |   { \n           [  key  :   string  ]  :   string  ; \n       },\n       i18n  ?:   I18n   |   boolean                             // default = false (using global i18n struct)\n   )  :   string\n  Parameters     Name  Type  Default  Description    var_name  String   The name of the variable that will store the message reference. The   var_name  can be in any level of the instance variable or global variable (e.g.   global.my_obj.my_msg ,   my_obj.my_msg ,   my_arr.0 ,   my_struct.my_msg , etc.).   key  String   The message key you want to reference (e.g.   hello ,   button.text ,   menu.help.about , etc.).   data  Real | Array | 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\" } ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String  (message based on the   key  in the   current locale  of the   i18n  struct)  Examples      // assume the system is initialized on global variable\n   \n   // the variable name is \"msg\"\n   msg   =   i18n_create_ref_message  (  \"msg\"  ,   \"hello\"  );      \n   \n   // the variable name is \"button_text\"\n   button_text   =   i18n_create_ref_message  (  \"button_text\"  ,   \"button.text\"  );\n   \n   // message ref in array, the variable name is \"my_arr\"\n   my_arr   =   [\n       i18n_create_ref_message  (  \"my_arr.0\"  ,   \"hello\"  ),         // this reference is created in index 0\n       i18n_create_ref_message  (  \"my_arr.1\"  ,   \"bye\"  ),           // this one is in index 1, separate the array index with dot \".\"\n       \"\"  ,\n       i18n_create_ref_message  (  \"my_arr.3\"  ,   \"long_text\"  )      // not always need to be created consecutively\n   ];\n   \n   // message ref in struct, the variable name is \"my_struct\"\n   my_struct   =   {\n       text :   i18n_create_ref_message  (  \"my_struct.text\"  ,   \"hello\"  ),                  // the key is \"hello\"\n       button :   i18n_create_ref_message  (  \"my_struct.button\"  ,   \"button.text\"  ),        // the var_name is this struct member name\n       about :   i18n_create_ref_message  (  \"my_struct.edit\"  ,   \"menu.help.about\"  ),       // separate the struct member with dot \".\"\n       nested : {\n           bye :   i18n_create_ref_message  (  \"my_struct.nested.bye\"  ,   \"bye\"  )            // you can nest the struct as deep as you want\n       },\n       arr : [\n           i18n_create_ref_message  (  \"my_struct.arr.0\"  ,   \"hello\"  ),                    // you can also create the reference in array\n           i18n_create_ref_message  (  \"my_struct.arr.1\"  ,   \"bye\"  )\n       ]\n   }\n   \n   // message ref in global variable, the variable name is \"global.hello_text\"\n   global.hello_text   =   i18n_create_ref_message  (  \"global.hello_text\"  ,   \"hello\"  );        // use \"global\" keyword like you're defining a global variable\n   global.button_text   =   i18n_create_ref_message  (  \"g.button_text\"  ,   \"button.text\"  );     // you can use \"g.\" shorthand for \"global.\"\n   \n   // message ref in global array\n   global.gb_arr   =   [\n       i18n_create_ref_message  (  \"g.gb_arr.0\"  ,   \"hello\"  ),           // same as you're creating the reference in instance variable,\n       i18n_create_ref_message  (  \"global.gb_arr.1\"  ,   \"bye\"  )         // but use \"global.\" or \"g.\" as the prefix\n   ];\n   \n   // message ref in global struct\n   global.gb_struct   =   {\n       text :   i18n_create_ref_message  (  \"global.gb_struct.text\"  ,   \"hello\"  ),             // same as you're creating the reference in instance variable,\n       button :   i18n_create_ref_message  (  \"g.gb_struct.button\"  ,   \"button.text\"  ),        // but use \"global.\" or \"g.\" as the prefix\n       menu : {\n           about :   i18n_create_ref_message  (  \"g.gb_struct.menu.about\"  ,   \"menu.help.about\"  )     // a nested struct in global struct\n       },\n       arr : [\n           i18n_create_ref_message  (  \"global.gb_struct.arr.0\"  ,   \"hello\"  ),              // you can also create the reference in array\n           i18n_create_ref_message  (  \"g.gb_struct.arr.1\"  ,   \"bye\"  )\n       ]\n   };\n     // change the locale, and the messages will be changed automatically!\n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :   i18n_set_locale  (  \"id\"  );   break  ;\n       case   \"id\"  :   i18n_set_locale  (  \"ja\"  );   break  ;\n       case   \"ja\"  :   i18n_set_locale  (  \"en\"  );   break  ;\n   }\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"  ,\n       \"button\"  : {\n           \"text\"  :   \"Click me!\"  ,\n           \"confirm\"  :   \"Are you sure?\"  ,\n           \"cancel\"  :   \"Cancel\"\n       },\n       \"menu\"  : {\n           \"file\"  :   \"File\"  ,\n           \"edit\"  :   \"Edit\"  ,\n           \"help\"  : {\n               \"about\"  :   \"About\"  ,\n               \"quit\"  :   \"Quit\"\n           }\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"  ,\n       \"button\"  : {\n           \"text\"  :   \"Klik saya!\"  ,\n           \"confirm\"  :   \"Apakah Anda yakin?\"  ,\n           \"cancel\"  :   \"Batal\"\n       },\n       \"menu\"  : {\n           \"file\"  :   \"File\"  ,\n           \"edit\"  :   \"Edit\"  ,\n           \"help\"  : {\n               \"about\"  :   \"Tentang\"  ,\n               \"quit\"  :   \"Keluar\"\n           }\n       }\n   }\n    The   var_name  is   not  the name of the message itself. You can name the   var_name  as you want, as long as it's   unique  (no duplicated name) in the same level of the variable.       For the detailed usage of   data  parameter, you can see the   Interpolation  and   Pluralization  section.   You're   heavily recommended  to create any i18n references in the   Create Event .  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":299,"path":300,"dir":198,"title":301,"description":302,"keywords":303,"body":304},"content:v1:5.api-reference:4.functions:i18n-draw-message.md","/v1/api-reference/functions/i18n-draw-message","i18n_draw_message()","The i18n_draw_message() function is used to draw a localized text. It's a wrapper for the draw_text_* functions with convenient additional features, so you can use it just like the draw_text_* functions.",[202,203,204,205],"  i18n_draw_message()  The   i18n_draw_message()  function is used to draw a localized text. It's a wrapper for the   draw_text_*  functions with convenient additional features, so you can use it just like the   draw_text_*  functions.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_draw_message  (x, y, text, [data], [preset_name], [locale], [i18n]);\n     function   i18n_draw_message  (\n       x  :   number  ,\n       y  :   number  ,\n       text  :   string  ,\n       data  ?:   number   |   any  [],\n       preset_name  ?:   string  ,\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    x  Real   The   x  position to draw the text (e.g.   room_width / 2 ).   y  Real   The   y  position to draw the text (e.g.   room_height / 2 ).   text  String   The text to draw. You can pass a normal text, or a message key (start with   @: ) to draw a translated text (e.g.   \"Hello World!\" ,   my_text , or   \"@:hello\" ).   data  Integer | Any[]   undefined  The data to pass to the message   pluralization  (  Integer ) or   indexed interpolation  (  Any[] ).   preset_name  String   \"\"  The name of the drawing preset to use (e.g.   \"header\" ,   \"body\" ,   \"title\" , etc.). Leave it empty to mark it as   dynamic  preset.   locale  String   \"\"  The locale code to use the drawing preset (and message key if the   text  parameter is a message key). Leave it empty if you don't want to use any drawing preset, or you want the message key to be static.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // pluralization\n   plural_index   =   1  ;\n   \n   // indexed interpolation\n   player_name   =   \"John\"  ;\n   intp_data   =   [  \"GM-I18n\"  , player_name];\n   apple   =   {\n       cost :   999999  ,\n       resc :   \"copper coins\"\n   };\n   \n   // add some drawing presets\n   i18n_add_drawings  ([  \"en\"  ,   \"id\"  ], [  \"title\"  ,   \"header\"  ,   \"body\"  ], [\n       new   I18nDrawings  (fnNotoSans, fa_center, fa_middle, #  FFFFFF  ,   1.2  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_middle, #  FFFFFF  ,   1  ,   0  ,   1  ),\n       new   I18nDrawings  (fnNotoSans, fa_left, fa_top, #  CCCCCC  ,   0.8  ,   0  ,   1  ,   -  1  ,   700  )\n   ]);\n     // use the \"header\" drawing preset from \"en\" locale\n   i18n_use_drawing  (  \"header\"  ,   \"en\"  );\n   \n   // and then draw the message\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  );            // dynamic message based on \"hello\" key message\n   draw_text  (  100  ,   50  ,   \"Hello, GM-I18n User!\"  );       // static text, the drawing preset still applied\n   \n   // use `draw_set_*` function if you want\n   draw_set_font  (fnNotoSansBold);\n   draw_set_halign  (fa_right);\n   draw_set_valign  (fa_bottom);\n   draw_set_color  (c_red);\n   draw_set_alpha  (  0.5  );\n   i18n_draw_message  (  100  ,   50  ,   \"@:bye\"  );       // dynamic message based on \"bye\" key message, but with custom drawing configuration\n   \n   // draw a dynamic message (\"hello\" key message) using dynamic \"header\" drawing preset\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  , ,   \"header\"  );\n   \n   // draw a dynamic message (\"bye\" key message) using \"body\" drawing preset on \"en\" locale\n   i18n_draw_message  (  100  ,   50  ,   \"@:bye\"  , ,   \"body\"  ,   \"en\"  );\n   \n   // draw a static text using the latest drawing preset (\"body\")\n   i18n_draw_message  (  100  ,   50  ,   \"This is a static text\"  );\n   \n   // draw a static message (\"hello\" key message) using \"title\" drawing preset in the current locale\n   i18n_draw_message  (  100  ,   50  ,   \"@:hello\"  , ,   \"title\"  );\n   \n   // draw a static message (\"selection\" key message) using the latest drawing preset on \"id\" with static pluralization\n   i18n_draw_message  (  100  ,   50  ,   \"@:selection\"  ,   0  , ,   \"id\"  );\n   \n   // draw a dynamic message (\"selection\" key message) using \"header\" drawing preset with dynamic pluralization based on the `plural_index` value\n   // bad practice, because the the latest `i18n_draw_message()` function already change the drawing preset to \"title\"\n   i18n_draw_message  (  100  ,   50  ,   \"@:selection\"  , plural_index,   \"title\"  );\n   \n   // draw a dynamic message (\"welcome\" key message) using \"body\" drawing preset with indexed interpolation based on the `intp_data` value\n   i18n_draw_message  (  100  ,   50  ,   \"@:welcome\"  , intp_data,   \"body\"  );\n   \n   // draw a static message (\"welcome\" key message) using the latest drawing preset on \"en\" with indexed interpolation\n   i18n_draw_message  (  100  ,   50  ,   \"@:welcome\"  , [\n       \"GM-I18n\"  ,   \"Bro\"\n   ], ,   \"en\"  );\n   \n   // draw a dynamic message (\"dialog.npc_1\" key message) using \"header\" drawing preset with indexed interpolation\n   i18n_draw_message  (  100  ,   50  ,   \"@:dialog.npc_1\"  , [\n       apple.cost, apple.resc\n   ],   \"header\"  );\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Bye World!\"  ,\n       \"selection\"  :   \"No | Yes\"  ,\n       \"welcome\"  :   \"Welcome to {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"This   \\\"  Bad Apple  \\\"   is cost {0} {1}!\"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"selection\"  :   \"Tidak | Ya\"  ,\n       \"welcome\"  :   \"Selamat datang di {0}, {1}!\"  ,\n       \"dialog\"  : {\n           \"npc_1\"  :   \"  \\\"  Bad Apple  \\\"   ini harganya {0} {1}!\"\n       }\n   }\n    For the detailed example of this function, you can see the   Drawing  section.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":306,"path":307,"dir":198,"title":308,"description":309,"keywords":310,"body":311},"content:v1:5.api-reference:4.functions:i18n-flatten-keys.md","/v1/api-reference/functions/i18n-flatten-keys","i18n_flatten_keys()","The i18n_flatten_keys() function is used to flatten the nested message keys into a single-level key.",[202,203,204,205],"  i18n_flatten_keys()  The   i18n_flatten_keys()  function is used to flatten the nested message keys into a single-level key.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_flatten_keys  (data_struct, [locale], [i18n], [prefix], [direct_write]);\n     function   i18n_flatten_keys  (\n       data_struct  :   { \n           [  key  :   string  ]  :   string  ; \n       },\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean  ,            // default = false (using global i18n struct)\n       prefix  ?:   string  ,                  // default = \"\" (no prefix)\n       direct_write  ?:   boolean            // default = true (write the flattened keys to the i18n struct)\n   )  :   void   |   string  []\n  Parameters     Name  Type  Default  Description    data_struct  Struct   The data struct to flatten the keys. The   key  is the message key, and the   value  is the message value (e.g.   { hello: \"Hello World!\" } ).   locale  String   \"\"  The locale code to flatten the keys for. Leave it empty to flatten the keys for the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.   prefix  String   \"\"   (INTERNAL USE ONLY)    The prefix to add to the flattened keys.   direct_write  Boolean   true  Write the flattened keys to the i18n struct. If   false , the function will return the flattened keys instead (in array of string).  Returns    Void  or   String[]  (if   direct_write  is   false )  Examples     // assume the system is initialized on global variable\n   \n   // create a nested data struct\n   var   data   =   {\n       hello:   \"Hello World!\"  ,\n       bye:   \"Goodbye World!\"  ,\n       greet: {\n           morning:   \"Good Morning!\"  ,\n           afternoon:   \"Good Afternoon!\"  ,\n           evening:   \"Good Evening!\"\n       }\n   };\n   \n   // flatten the keys\n   i18n_flatten_keys  (data,   \"en\"  );            // add the messages in the data struct to `en` locale\n   \n   // flatten the keys and return the flattened keys\n   var   keys   =   i18n_flatten_keys  (data,   \"en\"  , , ,   false  );       // [\"hello\", \"bye\", \"greet.morning\", \"greet.afternoon\", \"greet.evening\"]\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":313,"path":314,"dir":198,"title":315,"description":316,"keywords":317,"body":318},"content:v1:5.api-reference:4.functions:i18n-get-asset-from-ref.md","/v1/api-reference/functions/i18n-get-asset-from-ref","i18n_get_asset_from_ref()","The i18n_get_asset_from_ref() function is used to get the asset from the reference you created using the i18n_create_ref_asset() function.",[202,203,204,205],"  i18n_get_asset_from_ref()  The   i18n_get_asset_from_ref()  function is used to get the asset from the reference you created using the   i18n_create_ref_asset()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_asset_from_ref  (var_name, ref, [locale], [i18n]);\n     function   i18n_get_asset_from_ref  (\n       var_name  :   string  ,\n       ref  :   \"global\"   |   Instance   |   Object  ,\n       locale  ?:   string  ,                      // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean                 // default = false (using global i18n struct)\n   )  :   Asset\n  Parameters     Name  Type  Default  Description    var_name  String   Variable name based on the   var_name  parameter used in    i18n_create_ref_asset()  function (e.g.   global.my_obj.my_spr ,   my_obj.my_spr ,   my_arr.0 ,   my_struct.my_spr , etc.).   ref  String | Instance | Object   Reference name or instance id based on the ref in    i18n_create_ref_asset()  function. Recommended to pass   \"global\"  if the reference is created in global variable, or instance   id  if the reference is created in an instance.   locale  String   \"\"  The locale code to get the asset from. Leave it empty to get the asset from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Asset  Examples      // assume the system is initialized on global variable\n   \n   // create some asset references\n   my_spr   =   i18n_create_ref_asset  (  \"my_spr\"  , {\n       en: sprSplashEn,\n       id: sprSplashId,\n       ja: sprSplashJa\n   });\n   \n   my_arr   =   [\n       i18n_create_ref_asset  (  \"my_arr.0\"  , {\n           en: sndVoiceEn,\n           id: sndVoiceId,\n           ja: sndVoiceJa\n       })\n   ];\n   \n   global.my_obj   =   i18n_create_ref_asset  (  \"global.my_obj\"  , {\n       en: objPlayerEn,\n       id: objPlayerId,\n       ja: objPlayerJa\n   });\n   \n   global.my_font   =   {\n       my_font_1 :   i18n_create_ref_asset  (  \"g.my_font.my_font_1\"  , {\n           en: fnNotoSansEn,\n           id: fnNotoSansId,\n           ja: fnNotoSansJa\n       }),\n       ui_font : [\n           i18n_create_ref_asset  (  \"global.my_font.ui_font.0\"  , {\n               en: fnNotoSansEn,\n               id: fnNotoSansId,\n               ja: fnNotoSansJa\n           })\n       ]\n   };\n   \n   // see the function usage in the Key Pressed - Enter\n     // switch the locale\n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :   i18n_set_locale  (  \"id\"  );   break  ;\n       case   \"id\"  :   i18n_set_locale  (  \"ja\"  );   break  ;\n       case   \"ja\"  :   i18n_set_locale  (  \"en\"  );   break  ;\n   }\n     // get asset from \"my_spr\" reference in \"en\" locale\n   // use `instance_id_get()` to get the instance id\n   var   my_spr_en   =   i18n_get_asset_from_ref  (  \"my_spr\"  ,   instance_id_get  (self),   \"en\"  );\n   \n   // get asset from \"my_spr\" reference in current locale\n   var   my_spr   =   i18n_get_asset_from_ref  (  \"my_spr\"  ,   instance_id_get  (self));\n   \n   // get asset from \"my_arr\" reference in \"id\" locale\n   var   my_arr_id   =   i18n_get_asset_from_ref  (  \"my_arr.0\"  ,   instance_id_get  (self),   \"id\"  );\n   \n   // get asset from \"global.my_obj\" reference in current locale\n   // use \"global\" string to get the reference from global variable\n   var   my_obj   =   i18n_get_asset_from_ref  (  \"global.my_obj\"  ,   \"global\"  );\n   \n   // get asset from \"global.my_font.ui_font.0\" reference in \"ja\" locale\n   var   my_font_ja   =   i18n_get_asset_from_ref  (  \"global.my_font.ui_font.0\"  ,   \"global\"  ,   \"ja\"  );\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":320,"path":321,"dir":198,"title":322,"description":323,"keywords":324,"body":325},"content:v1:5.api-reference:4.functions:i18n-get-cache-id.md","/v1/api-reference/functions/i18n-get-cache-id","i18n_get_cache_id()","The i18n_get_cache_id() function is used to get the cache ID from the GM-I18n system.",[202,203,204,205],"  i18n_get_cache_id()  The   i18n_get_cache_id()  function is used to get the cache ID from the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_cache_id  (key, [data], [locale], [i18n]);\n     function   i18n_get_cache_id  (\n       key  :   string  ,\n       data  ?:   number   |   any  []   |   { \n           [  key  :   string  ]  :   any  ; \n       },\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   number\n  Parameters     Name  Type  Default  Description    key  String   The message key to get the cache ID from (e.g.   hello ,   bye ,   long_text , etc.).   data  Integer | Any[] | Struct   undefined  The data to pass to the message, whether it's for   pluralization  (  Integer ),   indexed interpolation  (  Any[] ), or   named interpolation  (  Struct ).   locale  String   \"\"  The locale code to get the cache ID from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to get the cache ID from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Integer  (the cache ID)  Examples      // assume the system is initialized on global variable\n   \n   // get the cache ID from \"hello\" key, from \"en\" locale\n   var   cache_id   =   i18n_get_cache_id  (  \"hello\"  , ,   \"en\"  );\n   \n   // get the cache ID from \"bye\" key, from current locale\n   var   cache_id2   =   i18n_get_cache_id  (  \"bye\"  );\n   \n   // get the cache ID from \"greet\" key, from current locale\n   // using named data interpolation\n   var   cache_id3   =   i18n_get_cache_id  (  \"greet\"  , {\n       name:   \"John\"                      // {name} = \"John\"\n   });\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"\n   }\n    The message caching isn't available for HTML5 export. So, this function will always return   -1  in HTML5.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":327,"path":328,"dir":198,"title":329,"description":330,"keywords":331,"body":332},"content:v1:5.api-reference:4.functions:i18n-get-cache-id-from-ref.md","/v1/api-reference/functions/i18n-get-cache-id-from-ref","i18n_get_cache_id_from_ref()","The i18n_get_cache_id_from_ref() function is used to get the cache ID from the reference you created using the i18n_create_ref_message() function.",[202,203,204,205],"  i18n_get_cache_id_from_ref()  The   i18n_get_cache_id_from_ref()  function is used to get the cache ID from the reference you created using the    i18n_create_ref_message()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_cache_id_from_ref  (var_name, [ref], [locale], [i18n]);\n     function   i18n_get_cache_id_from_ref  (\n       var_name  :   string  ,\n       ref  ?:   \"global\"   |   Instance   |   Object  ,\n       locale  ?:   string  ,                          // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean                     // default = false (using global i18n struct)\n   )  :   number\n  Parameters     Name  Type  Default  Description    var_name  String   Variable name based on the   var_name  parameter used in    i18n_create_ref_message()  function (e.g.   global.my_obj.my_msg ,   my_obj.my_msg ,   my_arr.0 ,   my_struct.my_msg , etc.).   ref  String | Instance | Object   undefined  Reference name or instance id based on the ref in    i18n_create_ref_message()  function. Recommended to pass   \"global\"  if the reference is created in global variable, or instance   id  if the reference is created in an instance.   locale  String   \"\"  The locale code to get the cache ID from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to get the cache ID from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Integer  (the cache ID)  Examples      // assume the system is initialized on global variable\n   \n   // create some message references\n   global.my_msg   =   i18n_create_ref_message  (  \"global.my_msg\"  ,   \"hello\"  );      \n   \n   my_arr   =   [\n       i18n_create_ref_message  (  \"my_arr.0\"  ,   \"bye\"  )\n   ];\n   \n   // get the cache ID from \"global.my_msg\" reference, from \"en\" locale\n   var   cache_id   =   i18n_get_cache_id_from_ref  (  \"global.my_msg\"  ,   \"global\"  ,   \"en\"  );\n   \n   // get the cache ID from \"my_arr.0\" reference, from current locale\n   var   cache_id2   =   i18n_get_cache_id_from_ref  (  \"my_arr.0\"  ,   instance_id_get  (self));\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n   }\n    The message caching isn't available for HTML5 export. So, this function will always return   -1  in HTML5.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":334,"path":335,"dir":198,"title":336,"description":337,"keywords":338,"body":339},"content:v1:5.api-reference:4.functions:i18n-get-drawing-presets.md","/v1/api-reference/functions/i18n-get-drawing-presets","i18n_get_drawing_presets()","The i18n_get_drawing_presets() function is used to get the all of the drawing presets name from the specified locale.",[202,203,204,205],"  i18n_get_drawing_presets()  The   i18n_get_drawing_presets()  function is used to get the all of the drawing presets name from the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_drawing_presets  ([locale], [i18n]);\n     function   i18n_get_drawing_presets  (\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   string  []\n  Parameters     Name  Type  Default  Description    locale  String   \"\"  The locale code to get the drawing preset(s) from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to get the drawing preset(s) from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String[]  Examples     // assume the system is initialized on global variable\n   // assume you have added the \"header\", \"body\", and \"button\" drawing presets\n   \n   // get the drawing presets from \"en\" locale\n   var   presets_en   =   i18n_get_drawing_presets  (  \"en\"  );\n   \n   // get the drawing presets from current locale\n   var   presets   =   i18n_get_drawing_presets  ();\n    If you pass non-existing locale code, this function will return an empty array.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":341,"path":342,"dir":198,"title":343,"description":344,"keywords":345,"body":346},"content:v1:5.api-reference:4.functions:i18n-get-drawings.md","/v1/api-reference/functions/i18n-get-drawings","i18n_get_drawings()","The i18n_get_drawings() function is used to get the drawing preset(s) struct from the specified locale.",[202,203,204,205],"  i18n_get_drawings()  The   i18n_get_drawings()  function is used to get the drawing preset(s) struct from the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_drawings  (preset_name, [locale], [i18n]);\n     function   i18n_get_drawings  (\n       preset_name  :   string   |   string  [],\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   I18nDrawings   |   I18nDrawings  []\n  Parameters     Name  Type  Default  Description    preset_name  String | String[]   The name of the drawing preset(s) to get (e.g.   \"header\" ,   \"body\" ,   \"title\" , etc.). You can pass a string for single preset, or an array of string for multiple presets (e.g.   [\"header\", \"body\", \"title\"] ).   locale  String   \"\"  The locale code to get the drawing preset(s) from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to get the drawing preset(s) from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns     I18nDrawings  or    I18nDrawings[]  Examples     // assume the system is initialized on global variable\n   // assume you have added the \"header\", \"body\", and \"button\" drawing presets\n   \n   // get the \"header\" drawing preset from \"en\" locale\n   var   header_en   =   i18n_get_drawings  (  \"header\"  ,   \"en\"  );\n   \n   // get the \"body\" drawing preset from current locale\n   var   body   =   i18n_get_drawings  (  \"body\"  );\n   \n   // get the \"body\" and \"button\" drawing presets from \"id\" locale\n   var   body_button_id   =   i18n_get_drawings  ([  \"body\"  ,   \"button\"  ],   \"id\"  );\n    If you pass non-existing locale code, this function will return empty    I18nDrawings  struct.       If you pass non-existing drawing preset name in current locale, the system will check the preset name in the fallback locale. If it's still not found, it will return empty    I18nDrawings  struct.   These structs are returned as   reference . So, if you change the value of the struct, it will affect the original struct in the   GM-I18n  system.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":348,"path":349,"dir":198,"title":350,"description":351,"keywords":352,"body":353},"content:v1:5.api-reference:4.functions:i18n-get-drawings-data.md","/v1/api-reference/functions/i18n-get-drawings-data","i18n_get_drawings_data()","The i18n_get_drawings_data() function is used to get the specific data from the drawing preset.",[202,203,204,205],"  i18n_get_drawings_data()  The   i18n_get_drawings_data()  function is used to get the specific data from the drawing preset.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_drawings_data  (preset_name, type, [locale], [i18n]);\n     function   i18n_get_drawings_data  (\n       preset_name  :   string  ,\n       type  :   I18N_DRAWING  ,               // I18N_DRAWING enum\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   number   |   Font   |   undefined\n  Parameters     Name  Type  Default  Description    preset_name  String   The name of the drawing preset to get the data from (e.g.   \"header\" ,   \"body\" ,   \"title\" , etc.).   type  I18N_DRAWING   The type of data to get from the drawing preset (e.g.   I18N_DRAWING.FONT ,   I18N_DRAWING.SEP , etc.). See the   I18N_DRAWING  constant for the list of available types.   locale  String   \"\"  The locale code to get the drawing preset from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to get the drawing preset from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Real  or   Font  or   undefined  Examples     // assume the system is initialized on global variable\n   // assume you have added the \"header\", \"body\", and \"button\" drawing presets\n   \n   // get the font from \"header\" drawing preset in \"en\" locale\n   var   font   =   i18n_get_drawings_data  (  \"header\"  ,   I18N_DRAWING  .  FONT  ,   \"en\"  );\n   \n   // get the text separation from \"body\" drawing preset in current locale\n   var   sep   =   i18n_get_drawings_data  (  \"body\"  ,   I18N_DRAWING  .  SEP  );\n   \n   // get the text width from \"button\" drawing preset in \"id\" locale\n   var   width   =   i18n_get_drawings_data  (  \"button\"  ,   I18N_DRAWING  .  WIDTH  ,   \"id\"  );\n    If you pass non-existing drawing preset name in current locale, the system will check the preset name in the fallback locale. If it's still not found, it will return   undefined .  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":355,"path":356,"dir":198,"title":357,"description":358,"keywords":359,"body":360},"content:v1:5.api-reference:4.functions:i18n-get-locale.md","/v1/api-reference/functions/i18n-get-locale","i18n_get_locale()","The i18n_get_locale() function is used to get the current locale code used by the GM-I18n system.",[202,203,204,205],"  i18n_get_locale()  The   i18n_get_locale()  function is used to get the current locale code used by the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_locale  ([i18n]);\n     function   i18n_get_locale  (\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   string\n  Parameters     Name  Type  Default  Description    i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String  Examples     // assume the system is initialized on global variable\n   \n   // get the current locale\n   var   locale   =   i18n_get_locale  ();\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":362,"path":363,"dir":198,"title":364,"description":365,"keywords":366,"body":367},"content:v1:5.api-reference:4.functions:i18n-get-locales.md","/v1/api-reference/functions/i18n-get-locales","i18n_get_locales()","The i18n_get_locales() function is used to get the all of the initialized locales in the GM-I18n system by using I18nLocaleInit struct.",[202,203,204,205],"  i18n_get_locales()  The   i18n_get_locales()  function is used to get the all of the initialized locales in the   GM-I18n  system by using    I18nLocaleInit  struct.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_locales  ([i18n]);\n     function   i18n_get_locales  (\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   I18nLocaleInit  []\n  Parameters     Name  Type  Default  Description    i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns     I18nLocaleInit[]  Examples     // assume the system is initialized on global variable\n   \n   // get the initialized locales\n   var   init_locales   =   i18n_get_locales  ();\n    The returned    I18nLocaleInit  struct contains the   code ,   name , and   file  property. So, if you want to get the locale code, you can use   init_locales[0].code , and so on, or just use    i18n_get_locales_code()  function instead.   These structs are returned as   reference . So, if you change the value of the struct, it will affect the original struct in the   GM-I18n  system.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":369,"path":370,"dir":198,"title":371,"description":372,"keywords":373,"body":374},"content:v1:5.api-reference:4.functions:i18n-get-locales-code.md","/v1/api-reference/functions/i18n-get-locales-code","i18n_get_locales_code()","The i18n_get_locales_code() function is used to get the all of the initialized locales code in the GM-I18n system.",[202,203,204,205],"  i18n_get_locales_code()  The   i18n_get_locales_code()  function is used to get the all of the initialized locales code in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_locales_code  ([include_non_init], [i18n]);\n     function   i18n_get_locales_code  (\n       include_non_init  ?:   boolean  ,       // default = false\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   string  []\n  Parameters     Name  Type  Default  Description    include_non_init  Boolean   false  Include the non-initialized locales code. If you add a locale using    i18n_add_locales() , and set the   include_non_init  to   true , this locale code will be included in the returned array.`   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String[]  Examples     // assume the system is initialized on global variable\n   \n   // add \"my\" locale\n   i18n_add_locales  (  \"my\"  );\n   \n   // get the initialized locales code\n   var   init_locales_code   =   i18n_get_locales_code  ();              // \"my\" locale will not be included\n   \n   // get the initialized and non-initialized locales code\n   var   all_locales_code   =   i18n_get_locales_code  (  true  );           // \"my\" locale will be included\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":376,"path":377,"dir":198,"title":378,"description":379,"keywords":380,"body":381},"content:v1:5.api-reference:4.functions:i18n-get-locales-name.md","/v1/api-reference/functions/i18n-get-locales-name","i18n_get_locales_name()","The i18n_get_locales_name() function is used to get the all of the initialized locales name in the GM-I18n system.",[202,203,204,205],"  i18n_get_locales_name()  The   i18n_get_locales_name()  function is used to get the all of the initialized locales name in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_locales_name  ([i18n]);\n     function   i18n_get_locales_name  (\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   string  []\n  Parameters     Name  Type  Default  Description    i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String[]  Examples     // assume the system is initialized on global variable\n   \n   // get the initialized locales name\n   var   init_locales_name   =   i18n_get_locales_name  ();\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":383,"path":384,"dir":198,"title":385,"description":386,"keywords":387,"body":388},"content:v1:5.api-reference:4.functions:i18n-get-message-from-ref.md","/v1/api-reference/functions/i18n-get-message-from-ref","i18n_get_message_from_ref()","The i18n_get_message_from_ref() function is used to get the message from the reference you created using the i18n_create_ref_message() function.",[202,203,204,205],"  i18n_get_message_from_ref()  The   i18n_get_message_from_ref()  function is used to get the message from the reference you created using the    i18n_create_ref_message()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_message_from_ref  (var_name, ref, [locale], [i18n]);\n     function   i18n_get_message_from_ref  (\n       var_name  :   string  ,\n       ref  :   \"global\"   |   Instance   |   Object  ,\n       locale  ?:   string  ,                      // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean                 // default = false (using global i18n struct)\n   )  :   string\n  Parameters     Name  Type  Default  Description    var_name  String   Variable name based on the   var_name  parameter used in    i18n_create_ref_message()  function (e.g.   global.my_obj.my_msg ,   my_obj.my_msg ,   my_arr.0 ,   my_struct.my_msg , etc.).   ref  String | Instance | Object   Reference name or instance id based on the ref in    i18n_create_ref_message()  function. Recommended to pass   \"global\"  if the reference is created in global variable, or instance   id  if the reference is created in an instance.   locale  String   \"\"  The locale code to get the message from. Leave it empty to get the message from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String  Examples      // assume the system is initialized on global variable\n   \n   // create some message references\n   msg   =   i18n_create_ref_message  (  \"msg\"  ,   \"hello\"  );      \n   \n   button_text   =   i18n_create_ref_message  (  \"button_text\"  ,   \"button.text\"  );\n   \n   global.hello_text   =   i18n_create_ref_message  (  \"global.hello_text\"  ,   \"hello\"  ); \n   global.button_text   =   i18n_create_ref_message  (  \"g.button_text\"  ,   \"button.text\"  );\n   \n   global.gb_struct   =   {\n       text :   i18n_create_ref_message  (  \"global.gb_struct.text\"  ,   \"hello\"  ),\n       button :   i18n_create_ref_message  (  \"g.gb_struct.button\"  ,   \"button.text\"  ), \n       menu : {\n           about :   i18n_create_ref_message  (  \"g.gb_struct.menu.about\"  ,   \"menu.help.about\"  ) \n       },\n       arr : [\n           i18n_create_ref_message  (  \"global.gb_struct.arr.0\"  ,   \"hello\"  ),\n           i18n_create_ref_message  (  \"g.gb_struct.arr.1\"  ,   \"bye\"  )\n       ]\n   };\n   \n   // see the function usage in the Key Pressed - Enter\n     // change the locale\n   switch   (  i18n_get_locale  ()) {\n       case   \"en\"  :   i18n_set_locale  (  \"id\"  );   break  ;\n       case   \"id\"  :   i18n_set_locale  (  \"en\"  );   break  ;\n   }\n     // get message from \"msg\" reference in \"en\" locale\n   // use `instance_id_get()` to get the instance id\n   var   msg_en   =   i18n_get_message_from_ref  (  \"msg\"  ,   instance_id_get  (self),   \"en\"  );\n   \n   // get message from \"button_text\" reference in current locale\n   var   button_text   =   i18n_get_message_from_ref  (  \"button_text\"  ,   instance_id_get  (self));\n   \n   // get message from \"global.hello_text\" reference in \"id\" locale\n   // use \"global\" string to get the reference from global variable\n   var   hello_text_id   =   i18n_get_message_from_ref  (  \"global.hello_text\"  ,   \"global\"  ,   \"id\"  );\n   \n   // get message from \"global.gb_struct.button\" reference in current locale\n   var   gb_struct_button   =   i18n_get_message_from_ref  (  \"global.gb_struct.button\"  ,   \"global\"  );\n   \n   // get message from \"global.gb_struct.arr.1\" reference in \"current\" locale\n   var   gb_struct_arr_1_ja   =   i18n_get_message_from_ref  (  \"global.gb_struct.arr.1\"  ,   \"global\"  );\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"  ,\n       \"button\"  : {\n           \"text\"  :   \"Click me!\"  ,\n           \"confirm\"  :   \"Are you sure?\"  ,\n           \"cancel\"  :   \"Cancel\"\n       },\n       \"menu\"  : {\n           \"file\"  :   \"File\"  ,\n           \"edit\"  :   \"Edit\"  ,\n           \"help\"  : {\n               \"about\"  :   \"About\"  ,\n               \"quit\"  :   \"Quit\"\n           }\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"  ,\n       \"button\"  : {\n           \"text\"  :   \"Klik saya!\"  ,\n           \"confirm\"  :   \"Apakah Anda yakin?\"  ,\n           \"cancel\"  :   \"Batal\"\n       },\n       \"menu\"  : {\n           \"file\"  :   \"File\"  ,\n           \"edit\"  :   \"Edit\"  ,\n           \"help\"  : {\n               \"about\"  :   \"Tentang\"  ,\n               \"quit\"  :   \"Keluar\"\n           }\n       }\n   }\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":390,"path":391,"dir":198,"title":392,"description":393,"keywords":394,"body":395},"content:v1:5.api-reference:4.functions:i18n-get-messages.md","/v1/api-reference/functions/i18n-get-messages","i18n_get_messages()","The i18n_get_messages() function is used to get the localized message from the GM-I18n system.",[202,203,204,205],"  i18n_get_messages()  The   i18n_get_messages()  function is used to get the localized message from the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_messages  (key, [data], [locale], [i18n], [create_cache]);\n     function   i18n_get_messages  (\n       key  :   string   |   string  [],\n       data  ?:   number   |   any  []   |   { \n           [  key  :   string  ]  :   any  ; \n       },\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean  ,            // default = false (using global i18n struct)\n       create_cache  ?:   boolean            // default = false (INTERNAL USE ONLY, create message cache)\n   )  :   string   |   string  []\n  Parameters     Name  Type  Default  Description    key  String | String[]   The message key(s) to get (e.g.   \"hello\" ,   \"bye\" ,   \"long_text\" , etc.). You can pass a string for single message, or an array of string for multiple messages (e.g.   [\"hello\", \"bye\", \"long_text\"] ).   data  Integer | Any[] | Struct   undefined  The data to pass to the message, whether it's for   pluralization  (  Integer ),   indexed interpolation  (  Any[] ), or   named interpolation  (  Struct ).   locale  String   \"\"  The locale code to get the message from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to get the message from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.   create_cache  Boolean   false   (INTERNAL USE ONLY)    Create a message cache for this message.  Returns    String  or   String[]  Examples      // assume the system is initialized on global variable\n   \n   // get a message from \"hello\" key, from \"en\" locale\n   msg   =   i18n_get_messages  (  \"hello\"  , ,   \"en\"  );         // \"Hello World!\"\n   \n   // get a message from \"bye\" key, from current locale\n   msg   =   i18n_get_messages  (  \"bye\"  );                 // \"Goodbye World!\" (if the current locale is \"en\")\n   \n   // get multiple messages from \"hello\" and \"bye\" key, from \"id\" locale\n   msg   =   i18n_get_messages  ([  \"hello\"  ,   \"bye\"  ], ,   \"id\"  );        // [\"Halo Dunia!\", \"Sampai jumpa Dunia!\"]\n   \n   // get a message from \"greet\" key, from current locale\n   // using named data interpolation\n   msg   =   i18n_get_messages  (  \"greet\"  , {\n       name:   \"John\"                      // {name} = \"John\"\n   });                                   // \"Hello, John!\" (if the current locale is \"en\")\n   \n   // get a message from \"greet_2\" key, from \"id\" locale\n   // using indexed data interpolation\n   player_name   =   \"John\"  ;\n   msg   =   i18n_get_messages  (  \"greet_2\"  , [\n       \"memancing\"  , player_name          // {0} = \"memancing\", {1} = player_name = \"John\"\n   ],   \"id\"  );                             // \"Hari yang cerah untuk memancing, 'kan, John?\"\n   \n   // get a message from \"shop.has_apple\" key, from current locale\n   // using static pluralization\n   apple_count   =   0  ;\n   msg   =   i18n_get_messages  (  \"shop.has_apple\"  , {\n       plural:   0  ,                                    // use the first form (index 0) (static)\n       plural_value: apple_count                     // interpolate the {plural_value} placeholder\n   });                                               // \"I don't have any apple\" (if the current locale is \"en\")\n   \n   // get multiple message from \"greet\" and \"shop.greet\" keys, from \"en\" locale\n   // using named data interpolation\n   msg   =   i18n_get_messages  ([  \"greet\"  ,   \"shop.greet\"  ], {\n       name:   \"John\"  ,                                     // {name} = \"John\"\n       shop_name:   \"The Chosen Apple\"                     // {shop_name} = \"The Chosen Apple\"\n   },   \"en\"  );                                             // [\"Hello, John!\", \"Welcome to The Chosen Apple, John!\"]\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"  ,\n       \"greet_2\"  :   \"What a nice day to {0}, right, {1}?\"  ,\n       \"shop\"  : {\n           \"greet\"  :   \"Welcome to {shop_name}, {name}!\"  ,\n           \"has_apple\"  :   \"I don't have any apple. | I have 1 apple. | I have {plural_value} apples.\"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"  ,\n       \"greet_2\"  :   \"Hari yang cerah untuk {0}, 'kan, {1}?\"  ,\n       \"shop\"  : {\n           \"greet\"  :   \"Selamat datang di {shop_name}, {name}!\"  ,\n           \"has_apple\"  :   \"Aku tidak punya apel. | Aku punya {plural_value} apel.\"\n       }\n   }\n    The   data  parameter is optional. You can leave it empty if you don't want to interpolate the message.       You can pass an array of keys to the   key  parameter to get multiple messages at once. The function will return an array of messages.       If you pass a data to the   data  parameter and you pass an array of keys to the   key  parameter, the data will be   applied to all of the messages .       For the detailed usage of this function, you can see the   Messages ,   Interpolation , and   Pluralization  section.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":397,"path":398,"dir":198,"title":399,"description":400,"keywords":401,"body":402},"content:v1:5.api-reference:4.functions:i18n-get-ref-asset.md","/v1/api-reference/functions/i18n-get-ref-asset","i18n_get_ref_asset()","Internal The i18n_get_ref_asset() function is used to track and get the valid reference you created using the i18n_create_ref_asset() function.",[202,203,204],"  i18n_get_ref_asset()   Internal  The   i18n_get_ref_asset()  function is used to track and get the valid reference you created using the    i18n_create_ref_asset()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_ref_asset  (index, [i18n]);\n     function   i18n_get_ref_asset  (\n       index  :   number  ,\n       i18n  ?:   I18n   |   boolean                 // default = false (using global i18n struct)\n   )  :   Instance   |   Struct   |   \"global\"\n  Parameters     Name  Type  Default  Description    index  Number   The index of the reference you want to get.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Instance ,   Struct , or   \"global\"     This function is used internally by the     i18n_update_refs()    function. You don't need to use this function directly, unless you know what you're doing.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":404,"path":405,"dir":198,"title":406,"description":407,"keywords":408,"body":409},"content:v1:5.api-reference:4.functions:i18n-get-ref-message.md","/v1/api-reference/functions/i18n-get-ref-message","i18n_get_ref_message()","Internal The i18n_get_ref_message() function is used to track and get the valid reference you created using the i18n_create_ref_message() function.",[202,203,204],"  i18n_get_ref_message()   Internal  The   i18n_get_ref_message()  function is used to track and get the valid reference you created using the    i18n_create_ref_message()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_get_ref_message  (index, [i18n]);\n     function   i18n_get_ref_message  (\n       index  :   number  ,\n       i18n  ?:   I18n   |   boolean                 // default = false (using global i18n struct)\n   )  :   Instance   |   Struct   |   \"global\"\n  Parameters     Name  Type  Default  Description    index  Number   The index of the reference you want to get.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Instance ,   Struct , or   \"global\"     This function is used internally by the     i18n_update_refs()    function. You don't need to use this function directly, unless you know what you're doing.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":411,"path":412,"dir":198,"title":413,"description":414,"keywords":415,"body":416},"content:v1:5.api-reference:4.functions:i18n-is-ready.md","/v1/api-reference/functions/i18n-is-ready","i18n_is_ready()","The i18n_is_ready() function is used to check if the GM-I18n system already load all of the initialized locale files.",[202,203,204,205],"  i18n_is_ready()  The   i18n_is_ready()  function is used to check if the   GM-I18n  system already load all of the initialized locale files.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_is_ready  ([i18n]);\n     function   i18n_is_ready  (\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   boolean\n  Parameters     Name  Type  Default  Description    i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Boolean  Examples      // assume the system is initialized on global variable\n     // check if the system is ready\n   if   (  i18n_is_ready  ()) {\n       // do something\n   }\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":418,"path":419,"dir":198,"title":420,"description":421,"keywords":422,"body":423},"content:v1:5.api-reference:4.functions:i18n-load-messages.md","/v1/api-reference/functions/i18n-load-messages","i18n_load_messages()","The i18n_load_messages() function is used to load the messages manually from the specified locale file.",[202,203,204,205],"  i18n_load_messages()  The   i18n_load_messages()  function is used to load the messages manually from the specified locale file.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_load_messages  (file, [locale], [i18n]);\n     function   i18n_load_messages  (\n       file  :   string   |   string  [],\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    file  String | String[]   The file path(s) to load the messages from (e.g.   \"~/langs/en.json\" ). Add   ~/  before the file path to load the file from the   working_directory . You can pass a string for single file, or an array of string for multiple files (e.g.   [\"~/langs/en2.json\", \"~/langs/en1.json\"] ).   locale  String   \"\"  The locale code to load the messages to (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to load the messages to the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   \n   // load the messages from \"en.json\" file, to \"en\" locale\n   i18n_load_messages  (  \"~/langs/en.json\"  ,   \"en\"  );\n   \n   // load the messages from \"en.json\" and \"en2.json\" files, to \"en\" locale\n   i18n_load_messages  ([  \"~/langs/en.json\"  ,   \"~/langs/en2.json\"  ],   \"en\"  );\n   \n   // load the messages from \"en.json\" file, to \"en\" locale, using custom i18n struct\n   i18n_load_messages  (  \"~/langs/en.json\"  ,   \"en\"  , my_i18n_struct);\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":425,"path":426,"dir":198,"title":427,"description":428,"keywords":429,"body":430},"content:v1:5.api-reference:4.functions:i18n-locale-exists.md","/v1/api-reference/functions/i18n-locale-exists","i18n_locale_exists()","The i18n_locale_exists() function is used to check if the specified locale is already initialized or added in the GM-I18n system.",[202,203,204,205],"  i18n_locale_exists()  The   i18n_locale_exists()  function is used to check if the specified locale is already initialized or added in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_locale_exists  (locale, [i18n]);\n     function   i18n_locale_exists  (\n       locale  :   string  ,\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   boolean\n  Parameters     Name  Type  Default  Description    locale  String   The locale code to check (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Boolean  Examples     // assume the system is initialized on global variable\n   // and you've set \"en\" and \"id\" as the initialized locales\n   \n   // check if \"en\" locale is available\n   var   is_en_exists   =   i18n_locale_exists  (  \"en\"  );      // true\n   \n   // check if \"id\" locale is available\n   var   is_id_exists   =   i18n_locale_exists  (  \"id\"  );      // true\n   \n   // check if \"ja\" locale is available\n   var   is_ja_exists   =   i18n_locale_exists  (  \"ja\"  );      // false\n   \n   // add \"ja\" locale\n   i18n_add_locales  (  \"ja\"  );\n   \n   // check again if \"ja\" locale is available\n   is_ja_exists   =   i18n_locale_exists  (  \"ja\"  );          // true\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":432,"path":433,"dir":198,"title":434,"description":435,"keywords":436,"body":437},"content:v1:5.api-reference:4.functions:i18n-message-exists.md","/v1/api-reference/functions/i18n-message-exists","i18n_message_exists()","The i18n_message_exists() function is used to check if the specified message key is already added in the specified locale.",[202,203,204,205],"  i18n_message_exists()  The   i18n_message_exists()  function is used to check if the specified   message key  is already added in the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_message_exists  (key, locale, [i18n]);\n     function   i18n_message_exists  (\n       key  :   string  ,\n       locale  :   string  ,\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   boolean\n  Parameters     Name  Type  Default  Description    key  String   The message key to check (e.g.   \"hello\" ,   \"bye\" ,   \"long_text\" , etc.).   locale  String   The locale code to check (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to check the message key in the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Boolean  Examples      // assume the system is initialized on global variable\n   // and you've added \"hello\" and \"bye\" messages to \"en\" and \"id\" locale\n   \n   // check if \"hello\" message is available in \"id\" locale\n   var   is_hello_exists   =   i18n_message_exists  (  \"hello\"  ,   \"id\"  );         // true\n   \n   // check if \"bye\" message is available in current locale\n   var   is_bye_exists   =   i18n_message_exists  (  \"bye\"  );                   // true\n   \n   // check if \"welcome\" message is available in \"en\" locale\n   var   is_welcome_exists   =   i18n_message_exists  (  \"welcome\"  ,   \"en\"  );     // false\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":439,"path":440,"dir":198,"title":441,"description":442,"keywords":443,"body":444},"content:v1:5.api-reference:4.functions:i18n-remove-messages.md","/v1/api-reference/functions/i18n-remove-messages","i18n_remove_messages()","The i18n_remove_messages() function is used to remove messages from the specified locale.",[202,203,204,205],"  i18n_remove_messages()  The   i18n_remove_messages()  function is used to remove messages from the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_remove_messages  (key, [locale], [i18n]);\n     function   i18n_remove_messages  (\n       key  :   string   |   string  [],\n       locale  ?:   string   |   string  []   |   \"all\"  ,       // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean                     // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    key  String | String[]   The message key(s) to remove (e.g.   \"hello\" ,   \"bye\" ,   \"long_text\" , etc.). You can pass a string for single message, or an array of string for multiple messages (e.g.   [\"hello\", \"bye\", \"long_text\"] ).   locale  String | String[] | \"all\"   \"\"  The locale code(s) to remove the message from. You can pass a string for single locale, or an array of string for multiple locales (e.g.   [\"en\", \"id\", \"ja\"] ). You can also pass   \"all\"  to remove the message from all locales.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   \n   // remove \"hello\" message from \"en\" locale\n   i18n_remove_messages  (  \"hello\"  ,   \"en\"  );\n   \n   // remove \"bye\" and \"long_text\" messages from \"id\" locale\n   i18n_remove_messages  ([  \"bye\"  ,   \"long_text\"  ],   \"id\"  );\n   \n   // remove \"hello\" message from all locales\n   i18n_remove_messages  (  \"hello\"  ,   \"all\"  );\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"long_text\"  :   \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"\n   }\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":446,"path":447,"dir":198,"title":448,"description":449,"keywords":450,"body":451},"content:v1:5.api-reference:4.functions:i18n-set-default-message.md","/v1/api-reference/functions/i18n-set-default-message","i18n_set_default_message()","The i18n_set_default_message() function is used to set the default message to be returned when the specified message key is not found in the specified locale and fallback locale.",[202,203,204,205],"  i18n_set_default_message()  The   i18n_set_default_message()  function is used to set the default message to be returned when the specified message key is   not  found in the specified locale and fallback locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_set_default_message  (message, [i18n]);\n     function   i18n_set_default_message  (\n       message  :   string  ,\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    message  String   The default message to be returned if the message key is not found in the specified locale and fallback locale (e.g.   \"N/A\" ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // assume the system is initialized on global variable\n   \n   // set the default message to \"N/A\"\n   i18n_set_default_message  (  \"N/A\"  );\n    The default message is only used for   message  fallback. It won't affect the localized asset fallback.       You can also set the default message in the    i18n_create()  function by passing the   default_message  in the   options  parameter.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":453,"path":454,"dir":198,"title":455,"description":456,"keywords":457,"body":458},"content:v1:5.api-reference:4.functions:i18n-set-locale.md","/v1/api-reference/functions/i18n-set-locale","i18n_set_locale()","The i18n_set_locale() function is used to change the current locale used by the GM-I18n system.",[202,203,204,205],"  i18n_set_locale()  The   i18n_set_locale()  function is used to change the current locale used by the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_set_locale  (code, [update_refs], [i18n]);\n     function   i18n_set_locale  (\n       code  :   string  ,\n       update_refs  ?:   boolean  ,           // default = true\n       i18n  ?:   I18n   |   boolean            // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    code  String   The locale code to switch to (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.).   update_refs  Boolean   true  Update all references (message and asset) to the new locale.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // assume the system is initialized on global variable\n   \n   // change the locale to \"id\"\n   i18n_set_locale  (  \"id\"  );\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":460,"path":461,"dir":198,"title":462,"description":463,"keywords":464,"body":465},"content:v1:5.api-reference:4.functions:i18n-unload-messages.md","/v1/api-reference/functions/i18n-unload-messages","i18n_unload_messages()","The i18n_unload_messages() function is used to unload the messages manually from the specified locale.",[202,203,204,205],"  i18n_unload_messages()  The   i18n_unload_messages()  function is used to unload the messages manually from the specified locale.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_unload_messages  (file, [locale], [i18n]);\n     function   i18n_unload_messages  (\n       file  :   string   |   string  [],\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    file  String | String[]   The file path(s) to unload the messages from (e.g.   \"~/langs/en.json\" ). Add   ~/  before the file path to unload the file from the   working_directory . You can pass a string for single file, or an array of string for multiple files (e.g.   [\"~/langs/en2.json\", \"~/langs/en1.json\"] ).   locale  String   \"\"  The locale code to unload the messages from (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to unload the messages from the   current locale .   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   \n   // unload the messages from \"en.json\" file, from \"en\" locale\n   i18n_unload_messages  (  \"~/langs/en.json\"  ,   \"en\"  );\n   \n   // unload the messages from \"en.json\" and \"en2.json\" files, from \"en\" locale\n   i18n_unload_messages  ([  \"~/langs/en.json\"  ,   \"~/langs/en2.json\"  ],   \"en\"  );\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":467,"path":468,"dir":198,"title":469,"description":470,"keywords":471,"body":472},"content:v1:5.api-reference:4.functions:i18n-update-cache.md","/v1/api-reference/functions/i18n-update-cache","i18n_update_cache()","The i18n_update_cache() function is used to update the cache value in the GM-I18n system.",[202,203,204,205],"  i18n_update_cache()  The   i18n_update_cache()  function is used to update the cache value in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_update_cache  (cache_id, [value], [i18n]);\n     function   i18n_update_cache  (\n       cache_id  :   number  ,\n       value  ?:   string  ,                   // default = \"\" (get the message from the stored key and data)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    cache_id  Integer   The cache ID to update. You can get it from    i18n_get_cache_id()  function.   value  String   \"\"  The new value to store in the cache. Leave it empty to get the message from based on the stored   key  and   data  in the cache.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   \n   // create a cache for \"hello\" key, from \"en\" locale\n   i18n_create_cache  (  \"hello\"  , ,   \"en\"  );                       // \"Hello World!\"\n   \n   // get the cache ID from \"hello\" key, from \"en\" locale\n   var   cache_id   =   i18n_get_cache_id  (  \"hello\"  , ,   \"en\"  );\n   \n   // update the cache value\n   i18n_update_cache  (cache_id,   \"Hello, GM-I18n User!\"  );      // \"Hello, GM-I18n User!\"\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"\n   }\n    The message caching isn't available for HTML5 export. So, this function will do nothing in HTML5.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":474,"path":475,"dir":198,"title":476,"description":477,"keywords":478,"body":479},"content:v1:5.api-reference:4.functions:i18n-update-drawings.md","/v1/api-reference/functions/i18n-update-drawings","i18n_update_drawings()","The i18n_update_drawings() function is used to update the drawing preset properties used by the i18n_draw_message() function.",[202,203,204,205],"  i18n_update_drawings()  The   i18n_update_drawings()  function is used to update the drawing preset properties used by the    i18n_draw_message()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_update_drawings  (preset_name, data, [locale], [i18n]);\n     function   i18n_update_drawings  (\n       preset_name  :   string  ,\n       data  :   [  string  , (  number   |   Font  )]   |   [  string  , (  number   |   Font  )][]   |   {\n           [  key  :   string  ]  :   number   |   Font\n       },\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    preset_name  String   The name of the drawing preset to update (e.g.   \"header\" ,   \"body\" ,   \"title\" , etc.).   data  [String, Real | Font] | [String, Real | Font][] | Struct   The data to update the drawing preset with. You can pass a single   [key, value]  pair, an array of   [key, value]  pair, or a struct with   { key: value }  pair. See the   I18N_DRAWING  interface for the list of available keys.   locale  String   \"\"  The locale code to update the drawing preset. Leave it empty to update the drawing preset for all locales.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n   // assume you have added the \"header\", \"body\", and \"button\" drawing presets\n   \n   text_alpha   =   1  ;\n   text_color   =   c_yellow;\n   \n   // update the font of \"header\" drawing preset in \"en\" locale\n   i18n_update_drawings  (  \"header\"  , [  \"font\"  , fnNotoSansBold],   \"en\"  );\n   \n   // update the font and color of \"body\" drawing preset in current locale\n   i18n_update_drawings  (  \"body\"  , [\n       [  \"font\"  , fnNotoSansBold], \n       [  \"color\"  , c_red]\n   ]);\n   \n   // update the font and color of \"button\" drawing preset in \"id\" locale\n   i18n_update_drawings  (  \"button\"  , { \n       font: fnNotoSansBold, \n       color: c_red \n   },   \"id\"  );\n     // if you want to update in event that updated every step, you can do it like this \n   // use array of [key, value] pair, which value can be a variable\n   // update the text alpha of \"header\" drawing preset in current locale\n   i18n_update_drawings  (  \"header\"  , [  \"alpha\"  , text_alpha]);\n   \n   // you can update multiple properties at once\n   i18n_update_drawings  (  \"header\"  , [\n       [  \"alpha\"  , text_alpha],\n       [  \"color\"  , text_color]\n   ]);\n   \n   // bad practice, don't do this! (using struct in event that updated every step)\n   i18n_update_drawings  (  \"header\"  , { alpha: text_alpha });\n     // in event that updated once, using struct is fine\n   i18n_update_drawings  (  \"header\"  , [  \"alpha\"  , text_alpha]);\n   \n   i18n_update_drawings  (  \"header\"  , [\n       [  \"alpha\"  , text_alpha],\n       [  \"color\"  , text_color]\n   ]);\n   \n   i18n_update_drawings  (  \"header\"  , { alpha: text_alpha });\n     Don't  pass a struct to the   data  parameter in event that updated every step (such as   Step Event ,   Draw Event , etc.). It may cause a performance issue.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":481,"path":482,"dir":198,"title":483,"description":484,"keywords":485,"body":486},"content:v1:5.api-reference:4.functions:i18n-update-loader.md","/v1/api-reference/functions/i18n-update-loader","i18n_update_loader()","The i18n_update_loader() function is used to update the loader function used by the GM-I18n system to load the initial locale files and refresh the used font in the drawing presets.",[202,203,204,205],"  i18n_update_loader()  The   i18n_update_loader()  function is used to update the loader function used by the   GM-I18n  system to load the initial locale files and refresh the used font in the drawing presets.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_update_loader  ([use_delta_time], [i18n]);\n     function   i18n_update_loader  (\n       use_delta_time  ?:   boolean  ,         // default = false\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    use_delta_time  Boolean   false  Use delta time to update the loader.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples      // assume the system is initialized on global variable\n     // update the loader\n   i18n_update_loader  ();\n    This function is   only  used if you're importing the text translation through JSON files.       You   need  to call this function in event that updated every step. I recommend to use   Step Event  for this.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":488,"path":489,"dir":198,"title":490,"description":491,"keywords":492,"body":493},"content:v1:5.api-reference:4.functions:i18n-update-plurals.md","/v1/api-reference/functions/i18n-update-plurals","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.",[202,203,204,205],"  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      i18n_update_plurals  (var_name, value, [update_refs], [i18n]);\n     function   i18n_update_plurals  (\n       var_name  :   string  ,\n       value  :   number  ,\n       update_refs  ?:   boolean  ,           // default = false\n       i18n  ?:   I18n   |   boolean            // default = false (using global i18n struct)\n   )  :   void\n  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      // assume the system is initialized on global variable, and the locale is \"en\"\n   \n   apple_count   =   0  ;\n   \n   // create a message references with pluralization\n   ref_msg   =   i18n_create_ref_message  (  \"ref_msg\"  ,   \"shop.has_apple\"  , {\n       plural  :   function  (  plural_value  ) {\n           switch   (  i18n_get_locale  ()) {\n               case   \"en\"  :\n                   return   (plural_value   \u003C=   0   ?   0   :   (plural_value   ==   1   ?   1   :   2  ));\n               case   \"id\"  :\n                   return   (plural_value   \u003C=   0   ?   0   :   1  );\n           }\n       },\n       plural_value:   0\n   });\n     // increase the apple count\n   apple_count  ++  ;\n   \n   // update the plural value in the message reference\n   i18n_update_plurals  (  \"ref_msg\"  , apple_count,   true  );\n     // decrease the apple count\n   apple_count  --  ;\n   \n   // update the plural value in the message reference\n   i18n_update_plurals  (  \"ref_msg\"  , apple_count,   true  );\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"  ,\n       \"greet_2\"  :   \"What a nice day to {0}, right, {1}?\"  ,\n       \"shop\"  : {\n           \"greet\"  :   \"Welcome to {shop_name}, {name}!\"  ,\n           \"has_apple\"  :   \"I don't have any apple. | I have 1 apple. | I have {plural_value} apples.\"\n       }\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"  ,\n       \"greet_2\"  :   \"Hari yang cerah untuk {0}, 'kan, {1}?\"  ,\n       \"shop\"  : {\n           \"greet\"  :   \"Selamat datang di {shop_name}, {name}!\"  ,\n           \"has_apple\"  :   \"Aku tidak punya apel. | Aku punya {plural_value} apel.\"\n       }\n   }\n    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.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":495,"path":496,"dir":198,"title":497,"description":498,"keywords":499,"body":500},"content:v1:5.api-reference:4.functions:i18n-update-refs.md","/v1/api-reference/functions/i18n-update-refs","i18n_update_refs()","The i18n_update_refs() function is used to update all references (message and asset) to the current locale. This function is automatically called when you change the locale using the i18n_set_locale() function.",[202,203,204,205],"  i18n_update_refs()  The   i18n_update_refs()  function is used to update all references (message and asset) to the current locale. This function is automatically called when you change the locale using the    i18n_set_locale()  function.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_update_refs  ([type], [i18n]);\n     function   i18n_update_refs  (\n       type  ?:   I18N_REF  ,                  // default = I18N_REF.ALL (update both message and asset)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   void\n  Parameters     Name  Type  Default  Description    type  I18N_REF   I18N_REF.ALL  The type of reference to update. You can use the    I18N_REF  constants to specify the type of reference you want to update (e.g.   I18N_REF.MESSAGES ,   I18N_REF.ASSETS ,   I18N_REF.ALL ).   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    Void  Examples     // assume the system is initialized on global variable\n   \n   // update all references (message and asset) to the current locale\n   i18n_update_refs  ();\n   \n   // update only message references to the current locale\n   i18n_update_refs  (  I18N_REF  .  MESSAGES  );\n   \n   // update only asset references to the current locale\n   i18n_update_refs  (  I18N_REF  .  ASSETS  );\n  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":502,"path":503,"dir":198,"title":504,"description":505,"keywords":506,"body":507},"content:v1:5.api-reference:4.functions:i18n-use-cache.md","/v1/api-reference/functions/i18n-use-cache","i18n_use_cache()","The i18n_use_cache() function is used to get the cache value in the GM-I18n system.",[202,203,204,205],"  i18n_use_cache()  The   i18n_use_cache()  function is used to get the cache value in the   GM-I18n  system.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_use_cache  (cache_id, [i18n]);\n     function   i18n_use_cache  (\n       cache_id  :   number  ,\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   string\n  Parameters     Name  Type  Default  Description    cache_id  Integer   The cache ID to get the value from. You can get it from    i18n_get_cache_id()  function.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns    String  (the cache value)  Examples      // assume the system is initialized on global variable\n   \n   // get the cache ID from \"hello\" key, from \"en\" locale\n   var   cache_id   =   i18n_get_cache_id  (  \"hello\"  , ,   \"en\"  );\n   \n   // get the cache value from the cache ID\n   var   msg   =   i18n_use_cache  (cache_id);           // \"\" (if the cache is not created yet)\n                                               // \"Hello World!\" (if the cache is already created)\n     {\n       \"hello\"  :   \"Hello World!\"  ,\n       \"bye\"  :   \"Goodbye World!\"  ,\n       \"greet\"  :   \"Hello, {name}!\"\n   }\n     {\n       \"hello\"  :   \"Halo Dunia!\"  ,\n       \"bye\"  :   \"Sampai jumpa Dunia!\"  ,\n       \"greet\"  :   \"Halo, {name}!\"\n   }\n    The message caching isn't available for HTML5 export. So, this function will always return an empty string (  \"\" ) in HTML5.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"id":509,"path":510,"dir":198,"title":511,"description":512,"keywords":513,"body":514},"content:v1:5.api-reference:4.functions:i18n-use-drawing.md","/v1/api-reference/functions/i18n-use-drawing","i18n_use_drawing()","The i18n_use_drawing() function is used to change the drawing preset used.",[202,203,204,205],"  i18n_use_drawing()  The   i18n_use_drawing()  function is used to change the drawing preset used.  This function can only be used after the    i18n_create()  function is called.  Syntax      i18n_use_drawing  (preset_name, [locale], [i18n]);\n     function   i18n_use_drawing  (\n       preset_name  :   string  ,\n       locale  ?:   string  ,                  // default = \"\" (use the current locale)\n       i18n  ?:   I18n   |   boolean             // default = false (using global i18n struct)\n   )  :   I18nDrawings   |   void\n  Parameters     Name  Type  Default  Description    preset_name  String   The name of the drawing preset to use (e.g.   \"header\" ,   \"body\" ,   \"title\" , etc.).   locale  String   \"\"  The locale code to use the drawing preset (e.g.   \"en\" ,   \"id\" ,   \"ja\" , etc.). Leave it empty to mark it as   dynamic  locale.   i18n  Boolean | I18n   false  The    I18n  struct reference, or leave it empty to use the   global  i18n struct.  Returns     I18nDrawings  or   Void  (if the drawing preset is not found)  Examples     // use the \"header\" drawing preset from \"en\" locale\n   i18n_use_drawing  (  \"header\"  ,   \"en\"  );\n   \n   // use the \"body\" drawing preset from \"id\" locale\n   i18n_use_drawing  (  \"body\"  ,   \"id\"  );\n   \n   // use the \"header\" drawing preset from \"ja\" locale in instance-scoped i18n struct\n   i18n_use_drawing  (  \"header\"  ,   \"ja\"  , i18n);\n   \n   // use the \"body\" drawing preset for dynamic locale\n   i18n_use_drawing  (  \"body\"  );\n   For the detailed example of this function, you can see the   Drawing  section.  html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",1781756102848]