Welcome to PGMZ! My goal is to make it easy for everyone to find and share great plugins for creating amazing games. As a plugin developer myself, I'm excited to grow this community with all of you.
Convert I18N Texts - ConvertI18NTexts.js
Plugin desc : Converts all the texts used in a game to escape characters and generates a JSON file with the original texts.
License : MIT License
Author : nz_prism
Website : https://github.com/nz-prism/RPG-Maker-MZ/blob/master/I18NTexts/js/plugins/ConvertI18NTexts.js
Desc page : https://github.com/nz-prism/RPG-Maker-MZ/blob/master/I18NTexts/js/plugins/ConvertI18NTexts.js
Download Page : https://raw.githubusercontent.com/nz-prism/RPG-Maker-MZ/master/I18NTexts/js/plugins/ConvertI18NTexts.js
File name : ConvertI18NTexts.js
Help of plugin :
* @target MZ
* @plugindesc Converts all the texts used in a game to escape characters and generates a JSON file with the original texts.
* @author nz_prism
* @url https://github.com/nz-prism/RPG-Maker-MZ/blob/master/I18NTexts/js/plugins/ConvertI18NTexts.js
*
* @help ConvertI18NTexts.js
* ver. 1.2.0
*
* [History]
* 06/04/2023 1.0.0 Released
* 06/04/2023 1.0.1 Fixed locales (ja-JP=>ja_JP, en-US=>en_US, ru-RU=>ru_RU)
* 06/05/2023 1.1.0 Added a functionality to prevent a double conversion.
* 10/10/2024 1.2.0 Added 2 parameters to control target texts.
*
* Converts all the texts used in a game to escape characters and generates a
* JSON file with the original texts. It makes changes to the database files
* directly. Make sure to make a backup before run this plugin. Note the
* author does not take any responsibilities for any damages caused by this
* plugin.
*
* When you run playtest with this plugin enabled, it will convert texts
* automatically and then terminate the app when it finishes converting. If
* MZ displays a dialog ”Project data has been modified exernally.”, click
* ”Yes” (if you clicked ”No”, restart MZ). Then, the new texts will appear
* on MZ. Note you must keep this plugin disabled unless you intend to convert
* texts. If you deployed a game with this plugin left enabled, it does not
* matter since it works only in playtest.
* After converting, all the target texts, such as database or event ones, are
* replaced with the corresponding texts. Plus, for the first time, a JSON file
* ”I18NTexts.json” will be generated in ”data” folder. For the second time or
* later, the JSON file will be updated. It contains all the texts which had
* been populated on the database. By using another plugin
* ”DisplayI18NTexts.js”, texts referred from the JSON file based on the
* language option will be displayed.
*
* Make sure to set the plugin parameters below before running;
* Source Language: Specify a language in which the database texts are written.
* It will be used to specify the language under which the original texts are
* populated in the JSON file.
* Target Language: Specify the language whose texts will be replaced with
* after converting. Make sure to choose ”Escape Character” for the first
* time. The texts on the database will be replaced with the corresponding
* ones in a language specified to this parameter. If Escape Characer is
* specified, the texts will be replaced with ”¥I18N[n]” (n is its ID). If
* another language is specified and I18NTexts.json contains the language,
* the texts will be replaced with the corresponding texts. Otherwise, the
* JSON file will be updated with the language keys.
* Languages to be Supported: Specify all the languages to be supported
* including the one used on the database. For the first time, all the
* language keys will be set in I18NTexts.json. Values other than those of
* Source Language will be populated with temporary texts ”temp[n]”.
* Convert Game Title: If you want to convert game title as well, set this
* parameter to true. However, since the title shown on the title bar
* remains as an escape character, you are recommended to leave it false.
* Convert Unused Texts: If true, texts which are not shown in a game by MZ
* default, such as troop or animation names, excluding notes and comments,
* will be converted as well.
* Convert Notes: If true, the notes on the database and the comments in event
* pages will be converted as well.
* Convert Empty Lines: If true, empty lines on the message-type events will
* be converted as well. In accordance with the previous version in which
* empty lines were to be converted, the default value is true.
* Convert Full Escape Character Texts: If true, texts composed of Escape
* Characters only will be converted as well. If such texts don’t have to be
* converted, set this parameter false. In accordance with the previous
* version in which full Escape Character texts were to be converted, the
* default value is true.
* Plugin Parameters: By specifying plugin names and their parameter names,
* the texts populated for the parameters will be converted as well. Note
* it converts only simple texts (string). String lists (string[]) and
* strings within structures (struct) can’t be converted. The text type
* plugin parameter names of OptionEx, required by DisplayI18NTexts.js, are
* populated by default.
*
* After conversion, this plugin will automatically be disabled. Plus, ”Source
* Language” and ”Target Language” will be swapped. This behavior prevents
* double conversion, which messes database and JSON texts.
*
* Note once you ran this plugin, do not change the values of plugin parameters
* below Target Texts afterwards. Plus, though it doesn’t matter to add items
* for the database or events, including event commands, do not delete items or
* change the order. Otherwise, it doesn’t work correctly due to ID changes.
* It doesn’t convert empty texts. If you populate a text for a field which was
* originally empty, or vice versa, texts will be messed due to ID changes.
* If you want to delete items or change orders, delete I18NTexts.json in data
* folder. It will be initialized by running this plugin.
*
* You are recommended to follow the examples below (these represent 2-language
* translation model: English and Japanese);
* 1. Make a backup of the project folder.
* 2. Specify ”English” and ”Japanese” for the plugin parameter ”Languages to
* be Supported”.
* 3. Specify ”English” for the plugin parameter ”Source Language”.
* 4. Specify ”Escape Character” for the plugin parameter ”Target Language”.
* 5. Set the plugin parameters under ”Target Texts” to values you wish.
* 6. Enable ConvertI18NTexts.js.
* 7. Run playtest.
* 8. Confirm all the target texts have been converted to escape characters.
* 9. Confirm I18NTexts.json has been generated in data folder.
* 10. Open I18NTexts.json and confirm the texts which had been populated on
* the database are populated for the values for ”en_US” keys and temporary
* texts ”temp[n]” are populated for ”ja_JP” keys.
* 11. Disable ConvertI18NTexts.js.
* 12. Specify ”English” and ”Japanese” for the plugin parameter ”Supported
* Languages” of DisplayI18NTexts.js.
* 13. Enable DisplayI18NTexts.js.
* 14. In I18NTexts.json, populate some texts for ”en_US” keys translated from
* those for ”ja_JP” keys (the texts shown on the option screen are
* recommended).
* 15. Run playtest and open the option screen.
* 16. For ”Language”, switch English and Japanese and confirm the texts you
* populated in 14 are correctly translated.
* 17. Repeat 14 - 16 until all the texts are translated.
*
* Leave the temporary texts (temp[n]) as they are until you translate them.
* If they are empty string, this plugin doesn’t work correctly.
*
* You can restore original texts from the escape characters by running this
* plugin with ”Escape Character” set for ”Source Language” and the original
* language for ”Target Language”. Confirm texts on the database or events
* are correctly restored.
* You can also update I18NTexts.json. For example, the databese language is
* English. Even if you made some changes to the database texts, the texts
* within I18NTexts.json are yet to be changed. By running this plugin with
* ”English” set for both ”Source Language” and ”Target Language”,
* I18NTexts.json will be updated.
*
* The language keys for I18NTexts.json
* English: en_US
* Japanese: ja_JP
* Simplified Chinese: zh_CN
* Traditional Chinese: zh_TW
* Korean: ko_KR
* French: fr_FR
* Italian: it_IT
* German: de_DE
* Spanish: es_ES
* Portuguese: pt_BR
* Russian: ru_RU
*
*
* This plugin is released under MIT license.
* https://opensource.org/licenses/mit-license.php
*
*
* @param sourceLanguage
* @text Source Language
* @desc Choose the source language, which is currently populated on the database.
* @default ja_JP
* @type select
* @option Escape Character (¥I18N[n])
* @value escape
* @option English
* @value en_US
* @option Japanese
* @value ja_JP
* @option Simplified Chinese
* @value zh_CN
* @option Traditional Chinese
* @value zh_TW
* @option Korean
* @value ko_KR
* @option French
* @value fr_FR
* @option Italian
* @value it_IT
* @option German
* @value de_DE
* @option Spanish
* @value es_ES
* @option Portuguese
* @value pt_BR
* @option Russian
* @value ru_RU
*
* @param targetLanguage
* @text Target Language
* @desc Choose the target language which will take place on the database after converting.
* @default escape
* @type select
* @option Escape Character (¥I18N[n])
* @value escape
* @option English
* @value en_US
* @option Japanese
* @value ja_JP
* @option Simplified Chinese
* @value zh_CN
* @option Traditional Chinese
* @value zh_TW
* @option Korean
* @value ko_KR
* @option French
* @value fr_FR
* @option Italian
* @value it_IT
* @option German
* @value de_DE
* @option Spanish
* @value es_ES
* @option Portuguese
* @value pt_BR
* @option Russian
* @value ru_RU
*
* @param languagesToBeSupported
* @text Languages to be Supported
* @desc Specify all the languages to be translated. The languages will be used for the keys in I18NTexts.json.
* @default [”en_US”,”ja_JP”]
* @type select[]
* @option English
* @value en_US
* @option Japanese
* @value ja_JP
* @option Simplified Chinese
* @value zh_CN
* @option Traditional Chinese
* @value zh_TW
* @option Korean
* @value ko_KR
* @option French
* @value fr_FR
* @option Italian
* @value it_IT
* @option German
* @value de_DE
* @option Spanish
* @value es_ES
* @option Portuguese
* @value pt_BR
* @option Russian
* @value ru_RU
*
* @param targetText
* @text Target Texts
* @desc Settings whether specific texts are to be converted.
*
* @param convertGameTitle
* @text Convert Game Title
* @desc If true, the game title will be converted. Leaving it false is recommended.
* @parent targetText
* @default false
* @type boolean
*
* @param convertUnusedTexts
* @text Convert Unused Texts
* @desc If true, texts unused in a game, such as troop or animation names, will be converted.
* @parent targetText
* @default false
* @type boolean
*
* @param convertNotes
* @text Convert Notes
* @desc If true, the ”Note” on the database items and an event command ”Comment” will be converted.
* @parent targetText
* @default false
* @type boolean
*
* @param convertEmptyLines
* @text Convert Empty Lines
* @desc If true, empty lines within message type events, including Comment, will be converted.
* @parent targetText
* @default true
* @type boolean
*
* @param convertFullEscapeCharacterTexts
* @text Convert Full Escape Character Texts
* @desc If false, texts composed of Escape Characters only will not be converted.
* @parent targetText
* @default true
* @type boolean
*
* @param pluginParameters
* @text Plugin Parameters
* @desc Specify plugin names and their parameter names, which will be converted.
* @parent targetText
* @default [”{¥”pluginName¥”:¥”OptionEx¥”,¥”parameterNames¥”:¥”[¥¥¥”switchABButtonsName¥¥¥”,¥¥¥”fastMessageName¥¥¥”,¥¥¥”dashSpeedName¥¥¥”,¥¥¥”windowskinName¥¥¥”,¥¥¥”windowToneRedName¥¥¥”,¥¥¥”windowToneGreenName¥¥¥”,¥¥¥”windowToneBlueName¥¥¥”,¥¥¥”windowOpacityName¥¥¥”,¥¥¥”defaultCommandName¥¥¥”]¥”}”]
* @type struct<pluginParameter>[]
*