ODW - Multi-Language System Plugin

● ARCHIVED · READ-ONLY
Started by r66r 145 posts Page 3 of 8 View original ↗
  1. Hi @Jacie0krece

    Good news, I might be able to offer you a "home-made" patch if needed and if VS don't make a fix. See the solution in this thread.:kaopride:

    So tell me again if/when you need to.
  2. r66r said:
    if VS don't make a fix.
    Team Visustella will never make a fix, they are too obtuse.
  3. Hello! Thank you so much for this fantastic plugin!

    However, is it possible to include a localization tag in the plugin? I'm working on a plugin and would like to find a way to incorporate it, That is what I attempted to do, but the results were not as expected.


    1680709364904.png
    1680709713801.png
  4. Hi @BabeElena

    Not sure what you want to achieve with a localization tag, since this plugin uses "language" subfolders to localize texts. But what I see, however, is that there seems to be a problem with the coding of the text. Indeed, "$${...}" is not the right pattern to use. There must be an extra "$" in your code somewhere.

    An alternative solution would be to use one of my plugin's native functions to translate the text before passing it to this.drawtext(), like this:

    Code:
    this.drawTextEx(ODW.MLS.getText(setBonusText), x, y, 412);

    Let me know if it works. And if needed, don't hesitate to contact me in PM to specify your need.
  5. Hello @TenraiEmiko

    I don't have a demo project (yet) to share with you, but here is some basic information that will be useful. By activating my plugin, you have the ability to configure several settings, including:
    • the label to display in the options window (which you can translate directly, as in the screenshot below)
    • the name of the folder where you will install the JSON files in the subfolders by language
    • the list of languages in your project
    Root Settings
    Settings.jpg

    In the list of languages, you have several parameters to enter:
    • the language code (for reference, but can be used in events via the ODW.MLS.getCurrentCode() function)
    • the language label, which will be used in the options window
    • the name of the folder that will contain the list of JSON files
    • the list of JSON files (without extension)
    • various labels that are hardcoded in RMMZ and that can be overloaded here
    Languages Settings => Example with English+French
    Settings_Languages.jpg
    Settings_Language_EN.jpg
    Settings_Language_FR.jpg

    Once my plugin is configured, all you have to do is create the folders and JSON files in your project.

    Folders & Files
    Languages_Files.jpg

    Now, to answer more specifically the question of the functions offered by my plugin:
    • ODW.MLS.getCurrentIndex() returns the index of the language in the list (in the above example 0 = English, 1 = French)
    • ODW.MLS.getCurrentCode() returns the language code (in the above example 'en' = English, 'fr' = French)
    My preference is to use ODW.MLS.getCurrentCode(), which is independent of the order of the languages and remains invariant if the order is changed.

    And as a bonus, here is how, thanks to this function, you can easily display images in different languages in your project. As you can see, you just need to use conditions with the script ODW.MLS.getCurrentCode() == '<code>' to then display the image with the corresponding language.

    Translated Pictures
    AddPicture.jpgAddPicture_Condition.jpg
    AddPicture_Files.jpg

    Note: I don't plan for the moment to make the display of images dynamic by proposing, for example, to put them in subfolders by language, like for JSON files. Maybe in a future major release.

    I hope this answers your questions. And if needed, don't hesitate to contact me in PM to specify your need.
  6. Hey, awesome plugin! Thank you. I have one question, tho:

    ist it possible to call the key for a nested JSON object? for example:

    JSON:
    {
    "test": {test2: "test3"}
    }

    How would i get the test3 result in a text box? I tried multiple variations like ${test.test2}, ${test[test2]}, ${test2} or ${testtest2} etc.. Is there a way, or is it simply not possible?

    regards
    Lufos
  7. Hi @Lufos

    The plugin does not handle nested JSON data. However, the text processing is recursive, so you can do something like this.

    Code:
    {
        "test1": "${test2}",
        "test2": "test3"
    }

    And in the message box, if you call ${text1}, the result will be test3. Useful, for example, if you have several JSON files and want to call up "standardized" text in one dialog without having to modify the same text everywhere it's used.

    Example
    File city.json
    Code:
    {
        "City.01": "London",
        "City.02": "Paris"
    }

    File absurddialog.json
    Code:
    {
        "dialog.01": "Where do yo live?",
        "dialod.02": "Me? In ${City.01}, and you?",
        "dialog.03": "In ${City.02}.",
        "dialog.04": "Oh! ${City.02} is quite beautiful!",
        "dialog.05": "${City.01} too."
    }
  8. Ok, thanks. Basically I'm just looking for a way to fold code in the JSON file. Comments are not allowed and multiple seperate objects in one file dont seem to work. So I was thinking about nested objects.
    Let's take the following example:
    JSON:
    {
    "Map01":"Training",
    
       "M01.Cut1":"Intro",
    
           "M01.Cut1.Actor2.1":    "bla",
    
           "M01.Cut1.Actor1.2":    "bla",
    
           "M01.Cut1.Actor2.3":    "bla",
    }

    I would like to group/fold the map and the cutscene code lines to improve readability in a large JSON file using Visual Studio Code. Is there a way to achieve this with this plugin? I'm completely new to coding and JSON stuff btw. :)
  9. Yes, you can totally do it that way. It's up to you to find a structure that's coherent and easy to understand.

    Spoiler
    Here's an example from one of my projects: the structure used in the maps.json file is MapName.EventName.MessageBox or MapName.EventName.MessageBox.Choice/Alternative.

    Code:
    {
        "Game.Setup.0001":   "What game mode would you like to play?",
        "Game.Setup.0001.1": "Fast: be the richest after 50 rounds",
        "Game.Setup.0001.2": "Standard: be the last one in the game",
        "Game.Setup.0002":   "What difficulty do you want to face?",
        "Game.Setup.0002.1": "Easy: show all the statistics + 600 \\G",
        "Game.Setup.0002.2": "Normal: show the main statistics + 400 \\G",
        "Game.Setup.0002.3": "Hard: show only your statistics + 200 \\G",
        "Game.Setup.0003":   "How many players will participate in this challenge?",
        "Game.Setup.0003.1": "2 players",
        "Game.Setup.0003.2": "3 players",
        "Game.Setup.0003.3": "4 players",
        "Game.Setup.0004":   "Welcome dear players! This abandoned kingdom was waiting for you.",
        "Game.Setup.0005":   "Now let's choose who will be the first to start!",
        "Game.Setup.0005.a": "Look at me my goddess, I'm doing it for you!\n\n(Press 'OK' to stop the dices)",
        "Game.Setup.0005.b": "I'll crush you like gnats!\n\n(Automatic playing dice)",
        "Game.Setup.0005.c": "You will regret letting me start!\n\n(Automatic playing dice)",
        "Game.Setup.0005.d": "The kingdom will be mine!\n\n(Automatic playing dice)",
        "Game.Setup.0006":   "And let player \\V[45] start!",
    
        "Game.End.0001": "The game is now over! And the winner is\\..\\..\\..",
        "Game.End.0002": "\\{\\{Player \\V[45] !!!\\}\\}",
        "Game.End.0003": "Congratulations my brave knight!\nYou have honored your goddess,\nand I thank you. The kingdom is ours now.",
        "Game.End.0004": "As if I would let the vermin steal this kingdom\nfrom me! Your goddess has abandoned you,\nwhy not join my evil forces?"
    }
  10. But can you do it in a way that it is possible to collapse/fold your lines of code? In your example, could you group game.end and game.setup into collapsable segments? As far is I know, in Visual Studio Code you would need to use multiple objects or comments (which arent allowed in JSON).
  11. I understand what you'd like. Unfortunately, you're getting into the area of code editors and how they handle JSON files, and that has nothing to do with RMMZ plugins. In any case, the ones I use can't fold lines into "flat" (1-level) JSON files.

    However, after a little research on the net, I came across this article on Visual Studio Code, which may answer your question.

    Spoiler
    1685778664292.png
    Source: https://code.visualstudio.com/docs/editor/codebasics
  12. Nice, that's exactly what I was looking for. Thank you!
  13. r66r said:

    Multi-Language System Plugin v1.0.1
    by Open Digital World

    View attachment 204558

    Introduction
    This plugin allows you to reference and translate all the texts of the game according to your needs. The texts are simply written in JSON files grouped in specific folders by language. The choice of the active language in the game is done only through the game options.

    Important: This plugin is a full rewritten and extended version of the "Ignis - Text Database" plugin by @Raizen. Also inspired by some features present in the "DKTools Localization" plugin by @DK.

    Features
    • Add an option to choose the language of the game.
    • Is able to translate almost all texts in the system, including hardcoded texts in the RPG Maker MZ code (see comments here).
    During a game play, go to the options to change the language by simply press or click on the languages option. The texts will be translated instantly.

    How to Use
    1. Configure your plugin (consult the help of the plugin).

    2. Create a folder in your game project and name it as set in the parameter <Languages Folder>. The name is case sensitive.

    3. In this folder, create a folder for each of your language and name it as set in the parameter <Languages -> Language Folder>. The name is case sensitive.

    4. In each language folders, create as many language files as you need, and declare them in the parameter <Languages -> Language Files>. The name is case sensitive, and the content has to respect the JSON structure.

    5. Develop your game and for each text to translate, use the following form:
    • In the text field of the RMMZ editor: ${<text code>}
    • In the language file: "<text code>": "<text to display in the language>"
    Don't forget to double escape your code like this:
    • \C[0] -> \\C[0] or \V[1] -> \\V[1]
    You can also nest texts together like this:
    • "Text1": "My text"
    • "Text2": "My text 1 is ${Text1}" -> My text 1 is My text
    6. You can also use the following functions as Script Call in your game:
    • ODW.MLS.getCurrentIndex()
    • ODW.MLS.getCurrentCode()
    • ODW.MLS.getCurrentLabel()

    Screenshots
    View attachment 204549View attachment 204550View attachment 204551View attachment 204552View attachment 204553View attachment 204554View attachment 204555View attachment 204556View attachment 204557

    Terms of Use
    This plugin is published under License MIT.

    Special Thanks
    Thanks to @Raizen for allowing me to extend his plugin and to publish a completely reworked version.


    Download Link
    ODW_MultiLanguageSystem.js (itch.io)

    Update Log
    Spoiler
    v1.0.0 - 21.10.2021
    - Initial release.
    v1.0.1 - 19.09.2022
    - Fixed a processing bug when the text has the ${} pattern twice or more.

    I need help with code checking!!

    I am so sorry for asking this, but I'm no expert, neither do I have some programmer friend and I keep getting the "Failed to load" error, so could someone help me with the code, like, I've checked it top to bottom again and again, but the error message keeps getting on my nerves and my anxiety won't let me progress if this is not finished :( :( :(

    ALSO: The file is for the VisuStella Element Status plugin, and I've reset it, so I doubt it is incompatibility or that I changed something that I shouldn't cause it's like recently downloaded

    1690692718496.png

    Code Images
    1690692387843.png
    1690692418558.png1690692425620.png
  14. Hi @AxoloStories

    The first step is to consult the console (press F8 or F12) to obtain more information about the loading error. In addition, I would try to parse the JSON file with something like this tool to see if there are any syntax errors. From the screenshots alone, I can't see any syntax errors at first glance.
  15. r66r said:
    Hi @AxoloStories

    The first step is to consult the console (press F8 or F12) to obtain more information about the loading error. In addition, I would try to parse the JSON file with something like this tool to see if there are any syntax errors. From the screenshots alone, I can't see any syntax errors at first glance.
    Omg thank you for sharing that tool, I never thought about something like that. I've solved the problem!! Turns out I've mistakenly put an extra "\" on a text line!!

    Thank you again for your help!! And for making this plugin :D
  16. Hi!
    This is a wonderful Plugin, I love it!

    Just a question, is it possible (in case I want to create a personalized "Choose your language" screen) to change the language via Script Call?
  17. Update v1.0.2 - 03.08.2023

    Update v1.0.2 available, which fixes a syntax error in a support function used via script call.

    Thanks to @becsantus for their help.



    Winthorp said:
    Just a question, is it possible (in case I want to create a personalized "Choose your language" screen) to change the language via Script Call?

    Yes, you can (now :eswt:) use the following code to change the active language via script call. Let me know if you have some issue with it (via PM if you like).

    Code:
    Mandatory:
    
    ODW.MLS.updateIndex(X); // X is the index of the language to activate
    ODW.MLS.loadDatabase(); // this reloads the texts for the new activcated language
    
    Optional (depends of the game scene context):
    
    SceneManager._scene.update(); // this update the current scene windows texts
    ODW.MLS.updateGameTitle(); // this change the game title in the html main window
  18. Hey @r66r ,
    first I want to thank you for this awesome plugin! It works like a charm and it makes fun to dive deeper into JSON.

    I'm creating an android game and have a little problem.
    Whenever the newest version of the game loads on my test-devices (at the moment via browser), the title screen shows the "code-strings" instead of the main language.

    This just happens on first load but for players it will look very odd when the game is released. Do you know any possible ways to avoid this? :)
  19. Hi @ChimaereJade

    I don't know the number or size of your JSON files, but perhaps not all of them were loaded by the time the title scene is displayed. One solution might be to trigger the initial loading earlier in the game launch process, even if it means setting a small timer (a few milliseconds) to make sure that all the texts are loaded when the game actually launches (as it is done when you change the language in the options).

    So I'd like to discuss and test a few solutions with you... and when the problem is solved, propose a corrective update for the community. Is it OK with you? If so, send me a PM to initiate the discussion. Thank you.
  20. It seems the problem is solved!
    Big thanks to @r66r for the quick help and taking care of the plugin since 2 years!