Iavra Localization (Development thread)

Discussion in 'JS Plugins In Development' started by Iavra, Nov 3, 2015.

Thread Status:
Not open for further replies.
  1. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    Core plugin

    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}.jsonHow to UseTo 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:
    Code:
    {    "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:
    Code:
    {    "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:

    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.
    Menu plugin

    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:EnglishHow to UseSimply 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.
    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: Dec 26, 2015
    #1
  2. Makeratore

    Makeratore Veteran Veteran

    Messages:
    187
    Likes Received:
    51
    Location:
    Rome, Italy
    First Language:
    Italian
    Can we use this also to translate EVERYTHING like plugin entries? For example, maybe there is a plugin that allow you to have custom messages or text for something. And inside of that plugin maybe there are a lot of terms. Can we translate them? Also, does it work for database, messages, map name, everything? I'm telling you these things because I used a script for Ace that made the user able to translate everything replacing them with a code. Then, in the external file, you can refer to that code and write your translation for every term with different codes.
     
    #2
  3. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    A complete list of what the plugin works for:

    Code:
    gameTitlecurrencyUnitterms (basic, params, commands, messages)actors (name, nickname, profile)classes (name)skills (name, description, message1, message2)items (name, description)weapons (name, description)armors (name, description)enemies (name)states (name, message1, message2, message3, message4)elementsskillTypesweaponTypesarmorTypesequipTypesmessage windows / choices
    It also supports custom categories, that you can access like this:
    Code:
    TextManager._text(category, key);
     
    Last edited by a moderator: Nov 3, 2015
    #3
    DangDut and Roguedeus like this.
  4. Makeratore

    Makeratore Veteran Veteran

    Messages:
    187
    Likes Received:
    51
    Location:
    Rome, Italy
    First Language:
    Italian
    Ok, thanks. But it won't support for other things like the ones I mentioned?
     
    #4
  5. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    Well, if you have a hardcoded string (or one retrieved via parameter) in some other plugin, it won't magically replace it, no.
     
    Last edited by a moderator: Nov 3, 2015
    #5
  6. Makeratore

    Makeratore Veteran Veteran

    Messages:
    187
    Likes Received:
    51
    Location:
    Rome, Italy
    First Language:
    Italian
    Ok, thank you for the answer!
     
    #6
  7. saronpasu

    saronpasu Villager Member

    Messages:
    26
    Likes Received:
    30
    Location:
    Japan
    First Language:
    Japanese
    hi.

    i am use this plugin.

    this plugin very powerful !!

    but, this case not switch language.

    test event case_A

    [​IMG]
    case_A result

    [​IMG]
    test event case_B

    [​IMG]
    case_B result

    [​IMG]
    Window_NameInput, reference $gameSystem.locale.

    And, Game_Troop.prototype.makeletterTable then reference $gameSystem.isCJK();

    NameInput and Troop letterTable can switch language this plugin?
     
    #7
  8. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    I see, the input buttons are hardcoded in Window_NameInput and not read from $dataSystem. But since multiple languages use the same letters, it's probably better to have them separate from this plugin (i actually haven't thought of non-latin languages when i made this...).
     
    Last edited by a moderator: Nov 5, 2015
    #8
  9. q8fft3

    q8fft3 Veteran Veteran

    Messages:
    82
    Likes Received:
    7
    First Language:
    arabic
    can any one give demo , i try to understand but i miss ? help.
     
    #9
  10. Shiroi Akuma

    Shiroi Akuma Shut up and take my Monet    ( ͡° ͜ʖ ͡°) Veteran

    Messages:
    350
    Likes Received:
    275
    Location:
    Right in front of your screen.
    First Language:
    German
    Primarily Uses:
    N/A
    @q8fft3 first you need to copy the plugin in the plugin folder edit: the name doesn't matter, then in game you create an event with a script call as content. Insert only

    IAVRA.I18N.exportJson(), As soon you activate the event somehow a Dialog with all in game Text open. Oh, I have to work, will write more later.... or better: Edit this post. D:
     
    Last edited by a moderator: Nov 14, 2015
    #10
    q8fft3 likes this.
  11. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    The plugin name shouldn't actually matter, since i don't rely on the PluginManager to retrieve my parameters.
     
    #11
    q8fft3 likes this.
  12. q8fft3

    q8fft3 Veteran Veteran

    Messages:
    82
    Likes Received:
    7
    First Language:
    arabic
    I used the plugin is amazing, but is to bad for arabic users don't supporting Special characters "unicode" in Windows_msssage.
     
    Last edited by a moderator: Nov 13, 2015
    #12
  13. Shiroi Akuma

    Shiroi Akuma Shut up and take my Monet    ( ͡° ͜ʖ ͡°) Veteran

    Messages:
    350
    Likes Received:
    275
    Location:
    Right in front of your screen.
    First Language:
    German
    Primarily Uses:
    N/A
    Will export for show text entries also come? I noticed that no dialogue from "show text" has been exported. Aren't those the message windows?
     
    Last edited by a moderator: Nov 14, 2015
    #13
  14. Lee Sang

    Lee Sang Sang Hendrix Veteran

    Messages:
    104
    Likes Received:
    195
    Location:
    Vietnam
    First Language:
    Vietnamese
    Primarily Uses:
    RMMV
    I love the plugin, but is there anyway to write multi lines of text without getting "Uncaxsytax Error: Unexpected Token" error?

    I have an example here. 

    [​IMG]
     
    #14
  15. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    Sadly, JSON doesn't support real linebreaks in Strings. You'll need to replace those with "\n".

    I opted not to do this, since it would require me to browse through all events, common events and battle events in the game and is rather tedious to do. Personally, i think it's better to plan your game with multiple languages in mind, than to re-localize it afterwards, anyway.
     
    Last edited by a moderator: Nov 14, 2015
    #15
  16. Shiroi Akuma

    Shiroi Akuma Shut up and take my Monet    ( ͡° ͜ʖ ͡°) Veteran

    Messages:
    350
    Likes Received:
    275
    Location:
    Right in front of your screen.
    First Language:
    German
    Primarily Uses:
    N/A
    I planned, but so far the only solution is to work with conditional branches to let the player choose which language he would like, however that far too much work and the events get too confusing with many conditional branches. In combination your plugin would at least localize the menus. I guess I have to wait then for a multilanguage plugin, or hire someone. Anyways thank you. :)
     
    #16
  17. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    Oh, but it can localize your messages, it just won't export the existing ones.

    Say your language file contains this entry:

    Code:
    {    // ...other stuff    "text" : {        "myText" : "lalala"    }}
    The you could use \:[myText] inside "Show Text..." to import that entry.
     
    #17
    Shiroi Akuma likes this.
  18. Shiroi Akuma

    Shiroi Akuma Shut up and take my Monet    ( ͡° ͜ʖ ͡°) Veteran

    Messages:
    350
    Likes Received:
    275
    Location:
    Right in front of your screen.
    First Language:
    German
    Primarily Uses:
    N/A
    It's not 100% comfy without export, because I would need to write the text in the 1st and 2nd language + using the escape codes in the editor, instead of just rewriting the text in the file(s), but I think I like this solution too, thanks! :)  
     
    #18
  19. Densetsustudio

    Densetsustudio Villager Member

    Messages:
    7
    Likes Received:
    1
    First Language:
    german
    does not work with japanese language.. if you could add this and maybe be able to export and translate the show text message than this would be golden!
     
    #19
  20. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    I probably won't add Show Text export for now.


    How exactly does japanese not work? Does it work normally, without using this plugin?
     
    #20
Thread Status:
Not open for further replies.

Share This Page