GD Localization - Yet another L18N plugin

Hey!
So I was working on this localization plugin for my own game, Foxblade, and decided I'd go ahead and throw it up on Github in case anyone else finds it useful.

The plugin is designed to be really simple to use, so honestly there's not much to it. Localization files are stored in .csv files, designed to make it simple to edit in any standard spreadsheet application (Excel, OpenOffice, Google Sheets, etc), with a single key column and one translation column per language (based on specs provided by third party localization services, to make sure these files are as simple as possible for a third party to localize). It supports localizing all of the built-in RPG Maker text stuff (event text, event choices, scrolling text, party member names, menu items, battle text, items, skills, actions, etc). You can also localize image, video, and sound resources.

You can specify as many language files to load on startup as you'd like (as an example you can split up localization files by category). It also supports loading language files for each map, so for example you can store localization for a specific map's events into a file named after the map and it will be automatically loaded when the player enters that map (it will be unloaded as soon as the player transitions to another map, to keep memory usage reasonable).

Localization is also performed recursively, so any localized text can itself contain tokens which will be localized.

Plugin Parameters
  • Directory for language files - this is the directory where language files should be stored, relative to your game's base directory. The default is to put files in /data/lang
  • Directory to search for per-map language files - this is the directory where per-map language files should be stored. They should be named the same as the map's name (NOT its display name) with ".csv" appended (for example, if your map is MAP001, the associated language file would be MAP001.csv and would be put in this directory). The default is to put per-map files in /data/lang/maps
  • Default files to load for localization - A list of default localization files which are loaded immediately on game startup
  • List of supported language codes - A list of language codes which are supported by the game. This is used by the options screen to show a list of languages to choose from.
  • Default language code - The default language to set. The default is "en-us"
  • Key column name - The name of the column to look for localization keys. The default is "Key"
  • Localize image & sound resources - If true, allows images, videos, & sound files to be redirected depending on the current language. The default is "true"
  • Strict error mode - When strict mode is enabled, if any key cannot be located in currently loaded localization files an error will be displayed. Otherwise, the error will be silently logged to the console. The default is "false"
Usage

Anywhere you'd put text which would be displayed to the player (actor names, nicknames, profiles, item names & descriptions, skill messages, event show text, system terms, etc), you can simply put in a token of the form {{PUT_KEY_HERE}}. The localization plugin will search all currently loaded localization data for a row with a key column value of PUT_KEY_HERE, and will substitute that token with the value of the current language column. If the key could not be found, or there is no language column for the current language, it will simply paste in the text PUT_KEY_HERE unless strict mode is enabled (in which case an error will be displayed and the game halted).

You can also parameterize text. For example, if the localized text of PUT_KEY_HERE is "Test message: %1 %2 %3", you can do this: {{PUT_KEY_HERE:"parameter 1" "parameter 2" "parameter 3"}} and each quoted text will be used to replace %1, %2, and %3 respectively.

For image, video, & sound resources, instead of defining an arbitrary key you will put the original path to the resource in the Key column, and put a redirected path in the language column.

At runtime, calls to load these resources will automatically be redirected to the correct path depending on the selected language.

Script API

All of these can be called from a Script call in an event, or they can be called from other plugins.
JavaScript:
L18NManager.getLanguage(langCode)       // get the current language code
L18NManager.setLanguage(langCode)       // set the current language code
L18NManager.getLanguageList()           // get the list of supported languages
L18NManager.loadLanguageFile(langFile)  // load translations from the given localization file
L18NManager.localizeText(text)          // replace special tokens of the form {{KEY}} in the given text with translations fetched from all loaded localization files
L18NManager.localizeResource(url)       // return the path to the localized version of the given resource url, or the original url if that resource is not localized or resource localization is disabled

Anyway, the source code is here in case it's useful! You can do whatever you want, commercial or noncommercial. Attribution is not required, but appreciated.

Little update: added support for parameterizing tokens. I kept finding I wanted to do stuff like having a "Found {whatever item}!" message that just gets templated with item names, so now you can do that.

The syntax is I hope fairly simple, just add a colon to the end of the key part and put a list of space-separated quoted text. Like this:
Code:
{{KEY_GOES_HERE:"param A" "param B" "param C"}}

So for example if the translation of the above KEY_GOES_HERE is "Test message %1 %2 %3" then those will be substituted and you'll get "Test message param A param B param C".
Each parameter will get recursively localized, so you can do stuff like this:

Code:
{{MSG_OBTAIN_ITEM:"{{ITEM_POTION_NAME}}"}}

Also, it works with existing special message tags, so for example a Show Text in an event can do stuff like this:
Code:
{{EV001_TEXT_01:"\P[1]"}}
which provides the first party member's name as a parameter to the text.
Will this work on MZ using Fossil?
It seems that menu text added by plugins doesn't support localization. Any chance we can get a guide on how to fix this?
1723695434182.png
The short version is that wherever the plugin inserts its own text, you will likely need to modify the plugin to make it call into the localization manager to retrieve the correct string.

I'm heading to bed now, but I'll try and write up an example in the morning.
Whoops, I forgot to respond.

Anyway, the gist is if the plug-in doesn't, say, give you a way to customize things directly with JS snippets, then you will need to find anywhere the plug-in adds options to the UI and modify it to add a call to the localization manager.

For example, if a plug-in modifies the Options window, you can change code that does this:

JavaScript:
this.addCommand(optionNameHere, symbolNameHere);

To code that does this:

JavaScript:
this.addCommand(L18NManager.localizeText(optionNameHere), symbolNameHere)

Original thread: https://forums.rpgmakerweb.com/threads/gd-localization-yet-another-l18n-plugin.145927/