//============================================================================= // RPG Maker MZ - ConvertI18NTexts //============================================================================= /*: * @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.3.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. * 10/08/2025 1.3.0 Supported language addition and added 2 language support; * Polish, Turkey * * 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. * For the second time or later, a new language will be added to I18NTexts.json * by specifying the language, which is not listed for "Languages to be * Supported", for "Target Language". * * 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 * Polish: pl_PL * Turkey: tr_TR * * * 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 * @option Polish * @value pl_PL * @option Turkey * @value tr_TR * * @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 * @option Polish * @value pl_PL * @option Turkey * @value tr_TR * * @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 * @option Polish * @value pl_PL * @option Turkey * @value tr_TR * * @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[] * */ /*~struct~pluginParameter: * * @param pluginName * @text Plugin Name * @desc Specify the plugin name which contains texts to be converted as parameter values. * @type string * * @param parameterNames * @text Parameter Names * @desc Specify plugin parameter names whose value will be converted. * @type string[] * */ /*:ja * @target MZ * @plugindesc ゲーム中に使用されるあらゆる文字列を専用制御文字に変換し、元の文字列をJSONファイルとして出力します。 * @author nz_prism * @url https://github.com/nz-prism/RPG-Maker-MZ/blob/master/I18NTexts/js/plugins/ConvertI18NTexts.js * * @help ConvertI18NTexts.js * ver. 1.3.0 * * [バージョン履歴] * 2023/06/04 1.0.0 リリース * 2023/06/04 1.0.1 ロケール名を修正 (ja-JP=>ja_JP, en-US=>en_US, ru-RU=>ru_RU) * 2023/06/05 1.1.0 二重変換防止機能を追加 * 2024/10/10 1.2.0 変換対象を制御する2つのパラメータを追加 * 2025/10/09 1.3.0 言語追加をサポート、ポーランド語とトルコ語に対応 * * ゲーム中に使用されるあらゆる文字列を専用制御文字に変換し、元の文字列をJSON * ファイルとして出力します。本プラグインはデータベースの文字列を直接変更しま * す。ご使用前に必ずバックアップをお取りください。本プラグインを使用したこと * で生じたあらゆる不具合や損失について、作者は一切責任を負いません。 * * 本プラグインを有効にした状態でテストプレイを起動すると文字列自動変換が始ま * り、完了するとそのままテストプレイが終了します。その後ツクールで「プロジェ * クトデータが外部で変更されました」というダイアログが表示されたら「はい」を * 選択してください(「いいえ」を選択した場合はツクールを再起動してください)。 * これによって文字列の変更がツクールに反映されます。実際に文字列を変換すると * き以外は本プラグインを無効にしてください。なお有効にしたままデプロイメント * してしまったとしても、本プラグインはテストプレイ時にしか機能しませんので問 * 題ありません。 * 変換が完了するとデータベースやイベントのあらゆる変換対象文字列が、対応する * 文字列に変換されます。また初回起動時、「I18NTexts.json」ファイルがdataフォ * ルダ内に生成されます。二回目以降の起動の場合、同ファイルが更新されます。こ * のファイルには変換前、データベースに入力されていた全ての文字列が出力されま * す。別プラグインである「DisplayI18NTexts.js」を使用することで、オプション * で選択されている言語に応じた文字列を表示することが可能です。 * * 起動前に必ず以下のプラグインパラメータの設定を確認してください。 * ・「ソース言語」には、現在データベースに実際に入力されているテキストの言語 *  (例:日本語)を指定します。これは変換完了後、JSONファイルに書き込まれる *  文字列の言語の指定になります。 * ・「ターゲット言語」には、置換先言語を指定します。初回起動時は必ず「制御文 *  字」を選択してください。データベース等の文字列は変換完了後、ここで選択し *  た言語に対応する文字列に置き換わります。「制御文字」の場合は専用の数字が *  割り振られた制御文字「\I18N[n]」に置換されます。それ以外の言語の場合、 *  I18NTexts.jsonにターゲット言語が含まれていれば対応する文字列に置き換わ *  ります。含まれていない場合、新しくその言語のデータ枠が用意されます。 * ・「翻訳候補言語リスト」には、現在使用されている言語も含めて翻訳を検討して *  いる全ての言語を指定してください。初回起動時、ここで設定した全ての言語が *  I18NTexts.jsonのキーとして設定されます。ソース言語以外の言語の値には *  「temp[n]」という仮文字列が入力されます。 * ・ゲームタイトルも変換対象にしたい場合「ゲームタイトルの変換」をオンにして *  ください。ただしタイトルバーに表示されるタイトルは翻訳されないので、この *  パラメータをオンにすることは推奨されません。 * ・「未使用文字列の変換」をオンにすると、敵グループの名前やアニメーションの *  名前、イベントの名前といったツクール標準ではゲーム中表示されることのない *  文字列(メモ・注釈以外)も変換対象になります。 * ・「メモの変換」をオンにすると、データベースの各種「メモ」およびイベントの *  「注釈」も変換対象になります。 * ・「空行の変換」をオンにすると、メッセージ系イベントの空行も変換対象になり *  ます。言語によって適切な行数が異なるため、空行で行数を増やす場合などに使 *  用してください。空行が変換対象だった前バージョンに合わせるため、デフォル *  トはオンになっています。 * ・「全制御文字テキストの変換」をオンにすると、制御文字のみで構成されたテキ *  ストも変換対象になります。このようなテキストが翻訳不要である場合はオフに *  してください。このようなテキストが変換対象だった前バージョンに合わせるた *  め、デフォルトはオンになっています。 * ・「プラグインパラメータ」にプラグイン名およびそのプラグインのプラグインパ *  ラメータ名を指定することで、プラグインパラメータに入力されている文字列も *  変換対象になります。ただし変換できるのは通常の文字列(string)のみであり、 *  文字列のリスト(string[])や構造体(struct)の中の文字列は変換できません *  のでご注意ください。なおDisplayI18NTexts.jsの前提プラグインであるOptionEx *  の各種オプション項目名のプラグインパラメータ名は、あらかじめ指定されていま *  す。 * * 変換が完了すると、本プラグインは自動的に無効化されます。また、「ソース言語」 * と「ターゲット言語」が入れ替わります。誤って本プラグインを二重に実行すると * データベースやJSONファイルがおかしくなってしまうため、これを防ぐために用意 * された機能です。 * * 本プラグインを一度実行した後、次回以降の起動では「変換対象文字列」以下のパ * ラメータを変更しないでください。また、データベース項目やイベント(イベント * 中のイベントコマンドも含む)を追加することは問題ありませんが、削除したり順 * 番を変更したりしないでください。IDがずれて正常に変換できなくなってしまいま * す。なお空の文字列は変換対象になりません。元は空文字列だったデータに文字列 * を入力する、あるいはその反対の編集を行うとやはりIDがずれてしまいます。そう * した変更を加える必要がある場合は、dataフォルダ内のI18NTexts.jsonを削除して * ください。これにより初期化されます。 * * 本プラグインは以下の手順にて使用することを推奨します(ゲーム中の文字列とし * て日本語と英語の2ヶ国語を使用する場合の例です)。 * 1. プロジェクトフォルダのバックアップを取る * 2. プラグインパラメータ「翻訳候補言語リスト」に「日本語」と「英語」を指定 * する * 3. プラグインパラメータ「ソース言語」に「日本語」を選択する * 4. プラグインパラメータ「ターゲット言語」に「制御文字」を選択する * 5. 「変換対象文字列」以下のプラグインパラメータ設定をよく確認する * 6. ConvertI18NTexts.jsを有効にする * 7. テストプレイを実行する * 8. 全ての変換対象の文字列が制御文字に変換されていることを確認する * 9. dataフォルダ内にI18NTexts.jsonが生成されていることを確認する * 10. I18NTexts.jsonを開き、「ja_JP」というキーの値にツクール上に入力されてい * た文字列が、「en_US」というキーの値に「temp[n]」という仮文字列が設定さ * れていることを確認する * 11. ConvertI18NTexts.jsを無効にする * 12. DisplayI18NTexts.jsのプラグインパラメータ「使用言語」に「日本語」と「英 * 語」を指定する * 13. DisplayI18NTexts.jsを有効にする * 14. I18NTexts.json内の任意のデータの「en_US」キーの値に、「ja_JP」キーの値 * の文字列を翻訳した文字列を入力する(オプション画面にて表示される文字列 * 推奨) * 15. テストプレイを実行し、オプション画面を開く * 16. 「言語」にて日本語と英語を切り替え、14で入力した文字列が正常に翻訳され * ていることを確認する * 17. 全ての文字列の翻訳が完了するまで14〜16を繰り返す * * 仮文字列(temp[n])は正式に翻訳するまでの間はそのままにしてください。 * 削除して空文字列にしてしまうと不具合が生じます。 * * なおデータベース等の文字列を制御文字から元の言語の文字列に戻すこともできま * す。その場合「ソース言語」に「制御文字」を、「ターゲット言語」に制御文字以 * 外の言語を指定してテストプレイを実行してください。その後、データベースやイ * ベントの文字列が正常に変換されていることを確認してください。 * また、I18NTexts.jsonの内容を更新することもできます。例えばデータベース文字 * 列が日本語であるとします。データベース上で何らかの文字列に変更を加えたとし * ても、I18NTexts.jsonのそれに対応する文字列はまだ古いままです。「ソース言語」 * と「ターゲット言語」の両方に「日本語」を指定してテストプレイを実行すると、 * I18NTexts.jsonに変更が反映されます。 * 2回目以降の起動にて「ターゲット言語」に「翻訳候補言語リスト」にない言語を選 * 択して変換を実行することで、I18NTexts.jsonに途中から言語を追加することもでき * ます。 * * I18NTexts.jsonの言語別キー一覧 * 日本語: ja_JP * 英語: en_US * 中国語(簡体字): zh_CN * 中国語(繁体字): zh_TW * 韓国語: ko_KR * フランス語: fr_FR * イタリア語: it_IT * ドイツ語: de_DE * スペイン語: es_ES * ポルトガル語: pt_BR * ロシア語: ru_RU * ポーランド語: pl_PL * トルコ語: tr_TR * * * このプラグインはMITライセンスにてリリースされています。 * https://opensource.org/licenses/mit-license.php * * * @param sourceLanguage * @text ソース言語 * @desc 現在データベースやイベントに入力されている文字列の言語を選択してください。 * @default ja_JP * @type select * @option 制御文字(\I18N[n]) * @value escape * @option 日本語 * @value ja_JP * @option 英語 * @value en_US * @option 中国語(簡体字) * @value zh_CN * @option 中国語(繁体字) * @value zh_TW * @option 韓国語 * @value ko_KR * @option フランス語 * @value fr_FR * @option イタリア語 * @value it_IT * @option ドイツ語 * @value de_DE * @option スペイン語 * @value es_ES * @option ポルトガル語 * @value pt_BR * @option ロシア語 * @value ru_RU * @option ポーランド語 * @value pl_PL * @option トルコ語 * @value tr_TR * * @param targetLanguage * @text ターゲット言語 * @desc テストプレイ起動後に変換する、データベースやイベントの文字列の言語を選択してください。 * @default escape * @type select * @option 制御文字(\I18N[n]) * @value escape * @option 日本語 * @value ja_JP * @option 英語 * @value en_US * @option 中国語(簡体字) * @value zh_CN * @option 中国語(繁体字) * @value zh_TW * @option 韓国語 * @value ko_KR * @option フランス語 * @value fr_FR * @option イタリア語 * @value it_IT * @option ドイツ語 * @value de_DE * @option スペイン語 * @value es_ES * @option ポルトガル語 * @value pt_BR * @option ロシア語 * @value ru_RU * @option ポーランド語 * @value pl_PL * @option トルコ語 * @value tr_TR * * @param languagesToBeSupported * @text 翻訳候補言語リスト * @desc すべての翻訳候補言語を設定してください。ここで指定した言語がI18NTexts.jsonのキーとして追加されます。 * @default ["ja_JP","en_US"] * @type select[] * @option 日本語 * @value ja_JP * @option 英語 * @value en_US * @option 中国語(簡体字) * @value zh_CN * @option 中国語(繁体字) * @value zh_TW * @option 韓国語 * @value ko_KR * @option フランス語 * @value fr_FR * @option イタリア語 * @value it_IT * @option ドイツ語 * @value de_DE * @option スペイン語 * @value es_ES * @option ポルトガル語 * @value pt_BR * @option ロシア語 * @value ru_RU * @option ポーランド語 * @value pl_PL * @option トルコ語 * @value tr_TR * * @param targetText * @text 変換対象文字列 * @desc 特定の文字列を変換対象にするかどうかの設定です。 * * @param convertGameTitle * @text ゲームタイトルの変換 * @desc オンにするとゲームタイトルも変換対象になります。タイトルバーに表示されるタイトルがおかしくなるため、非推奨です。 * @parent targetText * @default false * @type boolean * * @param convertUnusedTexts * @text 未使用文字列の変換 * @desc オンにすると敵グループやアニメーションの名前など、ゲーム中に表示されない文字列も変換対象になります。 * @parent targetText * @default false * @type boolean * * @param convertNotes * @text メモの変換 * @desc オンにするとデータベース項目の「メモ」、イベントコマンド「注釈」も変換対象になります。 * @parent targetText * @default false * @type boolean * * @param convertEmptyLines * @text 空行の変換 * @desc オンにするとメッセージ系のイベント(注釈も含む)の空行も変換対象になります。 * @parent targetText * @default true * @type boolean * * @param convertFullEscapeCharacterTexts * @text 全制御文字テキストの変換 * @desc オンにすると制御文字のみで構成されたテキストも変換対象になります。 * @parent targetText * @default true * @type boolean * * @param pluginParameters * @text プラグインパラメータ * @desc 各種プラグインのプラグインパラメータを変換対象に指定します(複数設定可能)。 * @parent targetText * @default ["{\"pluginName\":\"OptionEx\",\"parameterNames\":\"[\\\"switchABButtonsName\\\",\\\"fastMessageName\\\",\\\"dashSpeedName\\\",\\\"windowskinName\\\",\\\"windowToneRedName\\\",\\\"windowToneGreenName\\\",\\\"windowToneBlueName\\\",\\\"windowOpacityName\\\",\\\"defaultCommandName\\\"]\"}"] * @type struct[] * */ /*~struct~pluginParameter:ja * * @param pluginName * @text プラグイン名 * @desc 変換したいパラメータのプラグイン名を入力してください。 * @type string * * @param parameterNames * @text パラメータ名 * @desc プラグインパラメータ名を入力してください(複数設定可能)。 * @type string[] * */ if (Utils.isNwjs() && Utils.isOptionValid("test")) { $dataI18nTexts = null; (() => { 'use strict'; const PLUGIN_NAME = "ConvertI18NTexts"; const pluginParams = PluginManager.parameters(PLUGIN_NAME); const SOURCE_LANGUAGE = pluginParams.sourceLanguage; const TARGET_LANGUAGE = pluginParams.targetLanguage; const CONVERTING_TO_ESCAPE = TARGET_LANGUAGE === "escape"; // const CONVERTING_FROM_ESCAPE = SOURCE_LANGUAGE === "escape"; const UPDATING_TEXTS = TARGET_LANGUAGE === SOURCE_LANGUAGE; const LANGUAGES_TO_BE_SUPPORTED = JSON.parse(pluginParams.languagesToBeSupported); if (!LANGUAGES_TO_BE_SUPPORTED.includes(SOURCE_LANGUAGE)) LANGUAGES_TO_BE_SUPPORTED.unshift(SOURCE_LANGUAGE); const CONVERT_GAME_TITLE = pluginParams.convertGameTitle === "true"; const CONVERT_UNUSED_TEXTS = pluginParams.convertUnusedTexts === "true"; const CONVERT_NOTES = pluginParams.convertNotes === "true"; const CONVERT_EMPTY_LINES = pluginParams.convertEmptyLines === "true"; const CONVERT_FULL_ESCAPE_CHARACTER_TEXTS = pluginParams.convertFullEscapeCharacterTexts === "true"; const PLUGIN_PARAMETERS = {}; for (const str of JSON.parse(pluginParams.pluginParameters)) { const obj = JSON.parse(str); PLUGIN_PARAMETERS[obj.pluginName] = JSON.parse(obj.parameterNames); } const FILE_PATH = "data/I18NTexts.json"; const ESCAPE_TEXT = "\\I18N[%1]"; const LANGUAGE_OPTION_NAMES = { "ja_JP":"言語", "en_US":"Language", "zh_CN":"语言", "zh_TW":"語言", "ko_KR":"언어", "fr_FR":"Langue", "it_IT":"Lingua", "de_DE":"Sprache", "es_ES":"Idioma", "pt_BR":"Linguagem", "ru_RU":"Язык", "pl_PL":"Język", "tr_TR":"Dil" }; const ALERT_INVALID_SOURCE_JP = "「ソース言語」が無効な値です。プラグインパラメータを再設定してください。"; const ALERT_INVALID_SOURCE_EN = "\"Source Language\" is set to invalid value. Reset the plugin parameter."; const ALERT_INVALID_TARGET_JP = "「ターゲット言語」が無効な値です。プラグインパラメータを再設定してください。"; const ALERT_INVALID_TARGET_EN = "\"Target Language\" is set to invalid value. Reset the plugin parameter."; const ALERT_INITIAL_SOURCE_ESCAPE_JP = "初回起動時は「ソース言語」に「制御文字」以外の言語を設定してください。"; const ALERT_INITIAL_SOURCE_ESCAPE_EN = "For the first time, you must not choose \"Escape Character\" for \"Source Language\"."; const ALERT_INITIAL_TARGET_NOT_ESCAPE_JP = "初回起動時は「ターゲット言語」に「制御文字」を設定してください。"; const ALERT_INITIAL_TARGET_NOT_ESCAPE_EN = "For the first time, you must choose \"Escape Character\" for \"Target Language\"."; const fs = require("fs"); if (fs.existsSync(FILE_PATH)) DataManager._databaseFiles.push({ name: "$dataI18nTexts", src: "I18NTexts.json" }); StorageManager.shouldConvertText = function(text) { if (!text) { return false; } else if (CONVERT_FULL_ESCAPE_CHARACTER_TEXTS) { return true; } else { text = text.replace(/\s/g, ""); text = text.replace(/\\/g, "\x1b"); text = text.replace(/\x1b\x1b/g, "\\"); text = text.replace(/\x1b[G$.|^!><{}]/gi, ""); while (text.match(/\x1b..?\[\d*\]/gi)) { text = text.replace(/\x1b..?\[\d*\]/gi, ""); } return text !== ""; } }; StorageManager.processSystemTexts = function(id, texts, update=false) { const systemHeader = "system-"; if (CONVERT_GAME_TITLE) { const title = $dataSystem.gameTitle; if (this.shouldConvertText(title)) { const titleEscape = ESCAPE_TEXT.format(id); if (update) { if (UPDATING_TEXTS) { texts[id][SOURCE_LANGUAGE] = title; } else { $dataSystem.gameTitle = CONVERTING_TO_ESCAPE ? titleEscape : texts[id][TARGET_LANGUAGE]; } } else { const titleObj = {"id":id, "identifier": systemHeader+"gameTitle"}; titleObj[SOURCE_LANGUAGE] = title; $dataSystem.gameTitle = titleEscape; texts.push(titleObj); } id++; } } const currency = $dataSystem.currencyUnit; if (this.shouldConvertText(currency)) { const currencyEscape = ESCAPE_TEXT.format(id); if (update) { if (UPDATING_TEXTS) { texts[id][SOURCE_LANGUAGE] = currency; } else { $dataSystem.currencyUnit = CONVERTING_TO_ESCAPE ? currencyEscape : texts[id][TARGET_LANGUAGE]; } } else { const currencyObj = {"id":id, "identifier": systemHeader+"currencyUnit"}; currencyObj[SOURCE_LANGUAGE] = currency; $dataSystem.currencyUnit = currencyEscape; texts.push(currencyObj); } id++; } const elementHeader = systemHeader + "element"; const elements = $dataSystem.elements; for (let i=1; i