Iavra Localization

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
Reserved for future text exporter/importer plugin (don't hate me, mods...).
 
Last edited by a moderator:
  • Like
Reactions: Val

Makeratore

Veteran
Veteran
Joined
Feb 9, 2014
Messages
188
Reaction score
51
First Language
Italian
Primarily Uses
RMMV
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:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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:

JAD94

The lunar knight
Veteran
Joined
Feb 18, 2014
Messages
664
Reaction score
190
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?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
818
First Language
English
Primarily Uses
Wonderful plugin. I love it.
 

NeroAkuryoo

Villager
Member
Joined
Nov 1, 2015
Messages
8
Reaction score
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:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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.
 

NeroAkuryoo

Villager
Member
Joined
Nov 1, 2015
Messages
8
Reaction score
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:

Parable Games

Warper
Member
Joined
Nov 7, 2015
Messages
3
Reaction score
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!
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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.
 

Parable Games

Warper
Member
Joined
Nov 7, 2015
Messages
3
Reaction score
0
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.
Ok, thank you! While I wait you rewrite the plugin, I will continue using my temp solution.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
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)
 

Parable Games

Warper
Member
Joined
Nov 7, 2015
Messages
3
Reaction score
0
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:



(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)
It worked perfectly! Thank you very much, iavra!
 
Last edited by a moderator:

AnnTenna

Villager
Member
Joined
Jan 14, 2016
Messages
20
Reaction score
9
First Language
Russian
Primarily Uses
Thank you for an interesting plugin. :)


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

srazysnake

Villager
Member
Joined
Feb 25, 2016
Messages
29
Reaction score
0
First Language
Korean
Primarily Uses
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:

oktchau

Veteran
Veteran
Joined
Jan 4, 2016
Messages
52
Reaction score
5
First Language
Portuguese
Primarily Uses
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Posts

Latest Profile Posts

2 huge market drops in 2 days. So glad I sold my non-dividend stocks about 2 weeks ago. And if the dividend ones drop heavily, hey more cheap stocks for me!
My tutorial is live! It covers using Yanfly's weapon unleash to replace the basic attack skill with a more dynamic version depending on which weapon type the actor has equipped. It also includes how to import a custom function used to generate a random number within supplied minimum and maximum values, used in the replaced skills, to give weapons a set damage range.
What can I sing for my sisters birthday...?

>.<'
Well, I'll have you know that I'm still around, looking for opportunity to resurface with some stuffs.
I like to think of Profile Posts as tiny homes, full of all kinds of unsuspecting suckers "future" friends.... Many of which are of course only going to be excited when a strange man in black suddenly shows up to say hi. :LZSexcite:

Forum statistics

Threads
94,511
Messages
921,516
Members
124,368
Latest member
Botch
Top