Iavra Localization

Discussion in 'JS Plugin Releases (RMMV)' started by Iavra, Dec 26, 2015.

  1. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    Note: Refer to the following posts for a detailed description of all subplugins belonging to this one.


    Author


    Iavra


    Terms of Use


    Free to use for both commercial and non-commercial games. Please give credit.


    Download


    Core: http://pastebin.com/DQjGF7DC


    Menu: http://pastebin.com/zLjzkeei
     
    Last edited by a moderator: Feb 10, 2016
    #1
  2. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    IAVRA.I18N.language; Returns the current language.
    IAVRA.I18N.language = lang; Sets the current language to lang.
    IAVRA.I18N.languages(); Returns a list of all available languages.
    IAVRA.I18N.localize(text); Localizes the given text.


    Plugin


    Iavra Localization - Core


    Description


    The core plugin for localization, which contains all logic to load text and convert escape codes.


    Parameters


    @param Escape Code
    @desc Code, that will be used to retrieve localized strings. "{key}" serves as placeholder for the text key.
    @default #{{key}}

    @param Languages
    @desc Comma-separated list of languages, that should be supported. The first entry will be used as the default.
    @default en

    @param File Path
    @desc Path to the language files to load. The sequence "{lang}" will be replaced with the languages entered above.
    @default {lang}.json




    How to Use


    To setup this plugin, register all supported languages inside the "Languages" parameter, separated by commas. You also need to place the corresponding files inside your project folder. So, for example, if you want to support the languages "en" (english) and "de" (german) and the parameter "File Path" is set to its default value, you'll need to add the two files "de.json" and "en.json" to the root folder of your project.


    The first language will automatically used as the default langage.


    During runtime, every instance of "#{...}" (can be changed via plugin parameter "Escape Code") will get replaced with a localized string, where "..." stands for a text key. So, if your language file looks like this:


    {
    "text.test": "This is a test text"
    }


    Every instance of "#{text.test}" will be replaced with "This is a test text". For better maintainability, it's also possible to split keys at dots:


    {
    "text": {
    "test": "This is a test text"
    }
    }


    The above example will result in the same key as the first one, but makes it easier to construct nested keys, for example for the names of all actors. Instead of objects, you can also use arrays, like this:


    {
    "text": [
    "Text 1",
    "Text 2",
    "Text 3"
    ]
    }


    This will create the keys "text.0", "text.1" and "text.2", each pointing to the text listed at that array index. If needed, you are free to combine the object and array notations.


    Keys can also contain keys themselves, which will be replaced recursively. This allows you, to define important strings, like city names, at a single position and reference it everywhere else:


    {
    "text": "Hi, my name is #{actor}",
    "actor": "Harold"
    }


    You can use all escape characters, like "\V[...]" inside the files, but will need to double the backslashes. Line breaks can be entered by using "\n", since JSON doesn't support real linebreaks inside strings.


    The plugin offers the following script calls:

    Code:
    IAVRA.I18N.language;         Returns the current language.
    IAVRA.I18N.language = lang;  Sets the current language to lang.
    IAVRA.I18N.languages();      Returns a list of all available languages.
    IAVRA.I18N.localize(text);   Localizes the given text.
     
    Last edited by a moderator: Feb 1, 2016
    #2
  3. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    Plugin


    Iavra Localization - Menu


    Description


    Adds a "Language" option to the options menu, that can be used to change game language on the fly.


    Parameters


    @param Option Label
    @desc Label to be used for the option in the options menu.
    @default Language

    @param Language Labels
    @desc Comma-separated list of "language:label" pairs, to be used for the language selection.
    @default en:English




    How to Use


    Simply place this plugin in your plugin list after "Iavra Localization - Core". The parameters "Option Label" and "Language Labels" are used to define the text to be shown. You are free to use escape codes inside those parameters, as well, though i recommend against localizing the language labels.
     
    Last edited by a moderator: Feb 1, 2016
    #3
    Mellye, Val and NeroAkuryoo like this.
  4. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    Reserved for future text exporter/importer plugin (don't hate me, mods...).
     
    Last edited by a moderator: Dec 26, 2015
    #4
    Val likes this.
  5. Makeratore

    Makeratore Veteran Veteran

    Messages:
    187
    Likes Received:
    51
    Location:
    Rome, Italy
    First Language:
    Italian
    Can you provide a very small demo with 2 or 3 sample languages? I'm trying to use these plugins, but I don't understand well how to use them properly.

    EDIT: Sorry, I think that I've figured out how the plugins work. Thanks anyway! :D
     
    Last edited by a moderator: Dec 27, 2015
    #5
    Zekromaster likes this.
  6. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    I created a small demo and linked it in the OP (didn't translate everything, but it should give a general idea). I don't have a personal webspace, so i picked a random freehoster...


    A small note, that i forgot to mention before: If your plugin contains special characters (for example german ä, ö, ü, ß), you should save the language files in UTF-8 (Notepad++ can do this, for example). Otherwise, the characters won't get displayed correctly.
     
    Last edited by a moderator: Dec 27, 2015
    #6
    Val and Makeratore like this.
  7. JAD94

    JAD94 The lunar knight Veteran

    Messages:
    664
    Likes Received:
    184
    Location:
    New York
    First Language:
    English
    Primarily Uses:
    RMMV
    Hey so this is a fantastic plug-in thank you! I downloaded the demo.dem but I'm not sure how to actually play it haha. How do I open the .dem file?
     
    #7
  8. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    Something seems to have gone wrong, while uploading the demo :/ I don't have it anymore, since i switched to a new computer since i made this plugin. The plugin shouldn't actually be too hard to use, though.
     
    #8
  9. DreamX

    DreamX Veteran Veteran

    Messages:
    816
    Likes Received:
    804
    First Language:
    English
    Wonderful plugin. I love it.
     
    #9
  10. NeroAkuryoo

    NeroAkuryoo Villager Member

    Messages:
    8
    Likes Received:
    0
    First Language:
    Portuguese
    EDIT¹: Managed to figure out how to write the json files. But I've read in the development threat that is possible to use the keys on plugins, anyone knows if it's possible and how to do it?


    EDIT²: Also, anyone knows if it's possible to make buttons text from plugins to change with this one?
     
    Last edited by a moderator: Mar 7, 2016
    #10
  11. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    The plugin replaces keys, when text is written on a window or bitmap. So, as long as the plugin displays its text via one of these options, it will be translated.
     
    #11
  12. NeroAkuryoo

    NeroAkuryoo Villager Member

    Messages:
    8
    Likes Received:
    0
    First Language:
    Portuguese
    Thanks for the quick answer. The problem was that I tried to use that "\\:[key]" formart that was used in the development thread. Traded it for the "#{key}" format and now it's working fine. You really saved my skin because I need to use this for my college course work.
     
    Last edited by a moderator: Mar 8, 2016
    #12
  13. Parable Games

    Parable Games Warper Member

    Messages:
    3
    Likes Received:
    0
    Greetings.


    I am using your plugin in my project, and it is working fine. However, when I use "Change Name" event, it shows #{(my_variables)} instead of char name (I am storing some char names in .json files because the names change as the language).


    How can I solve this? Temporarily I created a menu when the player choose the default char name or input a new name (first it blanks the char name then call change name screen).


    Thank you very much!
     
    #13
  14. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    I see...Window_NameEdit draws the actor name 1 character at a time, so it won't get replaced with the actual text. For now i don't have the time to fix it, but i'll see what i can do when i get to rewrite the plugin.
     
    #14
  15. Parable Games

    Parable Games Warper Member

    Messages:
    3
    Likes Received:
    0
    Ok, thank you! While I wait you rewrite the plugin, I will continue using my temp solution.
     
    #15
  16. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    839
    First Language:
    German
    I decided, that i won't support the input name scene out of the box. It won't be able to coexist together with games, that want to localize their character names, so i have to decide to go follow one of those routes. You can use the following snippet to resolve the character name prior to calling the scene:

    Code:
    (function($) {
        var alias_initialize = $.prototype.initialize;
        $.prototype.initialize = function(actor, maxLength) {
            actor._name = IAVRA.I18N.localize(actor._name);
            alias_initialize.call(this, actor, maxLength);
        }
    })(Window_NameEdit)
     
    #16
  17. Parable Games

    Parable Games Warper Member

    Messages:
    3
    Likes Received:
    0
    It worked perfectly! Thank you very much, iavra!
     
    Last edited by a moderator: Apr 9, 2016
    #17
  18. AnnTenna

    AnnTenna Villager Member

    Messages:
    20
    Likes Received:
    9
    Location:
    Russia
    First Language:
    Russian
    Thank you for an interesting plugin. :)


    It is very sad that there is no exporter / importer functions.  :( When you planning to add this?
     
    #18
  19. srazysnake

    srazysnake Villager Member

    Messages:
    29
    Likes Received:
    0
    Location:
    Korea
    First Language:
    Korean
    Thank  you! Very nice!


    found out that I can just use comma(,) on each text line and add words to create new lines.


    my question is... for a really long sentence- is there a way to put half of it under it? (pressing space in normal editing.)


    thank you, I hope for your reply.
     
    Last edited by a moderator: May 27, 2016
    #19
  20. oktchau

    oktchau Veteran Veteran

    Messages:
    50
    Likes Received:
    5
    First Language:
    Portuguese
    Thanks fort the great plugin. Very versatile. I just would like to add that Windows Defender has been giving false positive for Trojan:Win32/Spursint.A!cl
     on both scripts.
     
    #20
    srazysnake likes this.

Share This Page