MZ Changing image depending on language (VisuStella) [SOLVED]

Hello,

I'm using RPG Maker MZ and VisuStella's plugins and looking for a way to display different images/videos depending on the selected language. VisuStella's Message Core makes it possible to translate text and it works fine but my game has an intro movie and several images with text that cannot be translated in this manner.

So I considered making a conditional branch with a script call that could do that.

I tried all these and they don't work.

◆Conditional Branch: Script: $gameSystem.language() === 'en'
◆Text: Showing English Image
◆Show Picture: #1, "Image_English", Upper Left (0,0), (100%,100%), 255, Normal
◆
: Else
◆Conditional Branch: Script: $gameSystem._locale === 'en'
◆Text: Showing English Image (_locale)
◆Show Picture: #1, "Image_English", Upper Left (0,0), (100%,100%), 255, Normal
◆
: Else
◆Conditional Branch: Script: $gameVariables.value(ID) === 'en'
◆Text: Showing English Image (variable)
◆Show Picture: #1, "Image_English", Upper Left (0,0), (100%,100%), 255, Normal
◆
: Else
◆Text: No Match Found
◆
◆
◆
◆

Is there a different script code I should use, or is this doomed from the start?


~~EDIT~~
Here's the solution:

1. Create a small plugin - LocalizationHelper.js:
/*:
* @plugindesc Localization Helper for Dynamic Image Paths
* @target MZ
*/

(function() {
window.getLocalizedImagePath = function(imageName) {
const locale = ConfigManager.textLocale || 'en'; // default to 'en' if not set
return `/${locale}/${imageName}`;
};
})();

2. Ensure Image Files Exist in the Correct Folders. Here are my paths:

img/pictures/English
img/pictures/Polish

3. Create an event and use a script call to show the image:

var imagePath = getLocalizedImagePath("YourImageName.png");$gameScreen.showPicture(1, imagePath, 0, 0, 0, 100, 100, 255, 0);

Change "YourImageName.png" to the name of your file.

Hope this helps!
Try using JavaScript native property in place of the $gameSyste.language() which I don't even think that exists (although maybe with VisusTella plugins)

JavaScript:
window.navigator.language

You can find more details about it here


The correct code is $dataSystem.locale, the locale string is something like 'en_US', 'ko_KR', 'ja_JP', 'zh_CN', etc
However, visustella has its own locale system, you can get current settings using ConfigManager.textLocale, for example "English", "Japanese", ....
You can check their message core document if you want to setup localization in game.
Try using JavaScript native property in place of the $gameSyste.language() which I don't even think that exists (although maybe with VisusTella plugins)

JavaScript:
window.navigator.language

You can find more details about it here


Thank you! I'll give it a try.
The correct code is $dataSystem.locale, the locale string is something like 'en_US', 'ko_KR', 'ja_JP', 'zh_CN', etc
However, visustella has its own locale system, you can get current settings using ConfigManager.textLocale, for example "English", "Japanese", ....
You can check their message core document if you want to setup localization in game.
Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/changing-image-depending-on-language-visustella-solved.170769/