Author Topic: [XP][VXA] Localization  (Read 15319 times)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
[XP][VXA] Localization
« on: July 27, 2012, 03:39:00 AM »
Localization
Authors: ForeverZer0, KK20
Version: 1.1
Type: Multilingual Game Tool
Key Term: Game Utility

Introduction

This script adds support for creating games that support multiple languages. The files for each culture are in .ini format and located externally so that they can be easily translated and used by simply dropping the language file into the game's "Localization" folder.

Features

  • Uses IDs to get strings from external .ini files, which can be easily edited in any text editor, such as Notepad
  • Supports special characters used by non-English languages
  • Included message commands to simplify making your multilingual game, you use the command the same as you would the normal switch and variable commands
  • Also supports using in the Bitmap#draw_text methods so that custom scripts that draw onto Sprite bitmaps instead of Windows will still work without the need for customization
  • Automatically saves/loads the current culture

Screenshots

None.

Demo

[XP] Demo Link (Thank Google for the wonderful translations...)

Script

(click to show/hide)

(click to show/hide)

Instructions

Please see script for instructions.  The demo contains examples that will make much it much clearer.

(click to show/hide)

(click to show/hide)


Compatibility

No known compatibility issues. Custom Message systems may require slight modification, though have not been tested. I can offer support for to making them compatible on a "per system" basis.

Credits and Thanks

  • ForeverZer0, for the script
  • KK20, for the VXA edit

Author's Notes

Please report bugs/issues so that may be resolved.
Feel free to request compatibility fixes if you have a Custom Message System that does not work with the script.
« Last Edit: April 22, 2013, 10:37:01 PM by KK20 »
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #1 on: July 27, 2012, 08:12:28 AM »
Just a small note: IDs should be strings as well. It's much easier to keep stuff in mind if you have strings as IDs/keys since it's easier to remember Forest_of_Illusion_Entry_Dialog_15 than 312547.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Localization
« Reply #2 on: July 27, 2012, 04:03:00 PM »
There's actually nothing stopping you from using a string as it is right now, there would simply be a redundant "to_s" called on it. A string is actually what is passed to the API method.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Localization
« Reply #3 on: July 27, 2012, 04:43:30 PM »
This right here prevents us from using a string.
Code: [Select]
return string.gsub(/\\[Ll][Oo][Cc]\[([0-9]+)\]/) { self.read($1) }

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Localization
« Reply #4 on: July 27, 2012, 06:27:50 PM »
Ah, shit, you're right, I'm thinking ahead to the next step. I can make a quick fix later, it will be simple.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #5 on: July 27, 2012, 08:21:51 PM »
Also test if newlines are processed properly. I'm not sure the .ini format allows processing them just like that.

Code: (example) [Select]
Intro_001=A long, long time ago in a
galaxy far, far away.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6585
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Localization
« Reply #6 on: July 27, 2012, 09:08:04 PM »
Despite the minor detail, you still did a really nice job on this Zer0. It's a powerful script with so little code. Very well done!

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #7 on: July 27, 2012, 09:32:03 PM »
I agree, cleverly executed. Have you thought about adding a debug-only window pop-up if a string has not been replaced? It would make finding unlocalized strings easier.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Localization
« Reply #8 on: July 28, 2012, 02:04:56 AM »
Alrighty, I updated to allow strings as IDs as well. I also included the little pop-up window warning when strings are not found that Blizzard mentioned above (thanks).

After doing some testing and googling, Windows automatically escapes backslash characters within .ini files. This means that newline characters, etc. do not work. I spent about an hour trying to figure how to simply have the system look for escaped backslashes and convert them back, but I can't seem to get that to work.

I have also done a bit of messing around with Unicode characters, and am hitting a brick wall with that. Ruby 1.8.1 (RMXP's version) simply does not have enough Unicode support to be able to translate text into Chinese, Arabic, Japanese, and other languages like that. The strings are read being correctly from the .ini file (you can insert a "p text" in the read method before the return to see that much), but fail to be drawn correctly on windows. I have tried every sort of encoding combination, unpacking and repacking strings on the fly from UTF-8 to Latin, and nothing works. This is a issue with the underlying library that cannot be fixed with a script as far as I know how. Later version of Ruby (1.9 and above) fixed these issues, but I cannot find a proper work around that is gonna help when being stuck using Ruby 1.8.1.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #9 on: July 28, 2012, 11:48:14 AM »
You could use a custom .ini parser. Ruby 1.8.1 should properly read UTF8 encoded files. Just make sure that you skip the BOM at the beginning manually. You can refer to aprilui's Dataset::_loadTexts method to see how it's done. Keep in mind that Unicode != UTF8. I'm not sure if reading an .ini actually gives you Unicode characters. If yes, simply convert them to UT8. All my Input modules include a method for conversion, you can use that one.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Localization
« Reply #10 on: July 28, 2012, 07:12:40 PM »
No, you misunderstand, the text being read from the files is correct. That's not the problem, I can use "p text" and the characters display perfectly in the little pop-up window, but if when you try to draw it to a window, nothing works. I could manually remove the BOM and it would make no difference. The BOM only has an effect on WinAPI, and has nothing to do with Ruby. I am saying that RMXP cannot handle the text.

This is what I am talking about. Put this code in the editor:
Code: [Select]
$data_system = load_data('Data/System.rxdata')
$game_system = Game_System.new
chinese = '你好世界。'
window = Window_Base.new(160, 208, 320, 96)
window.contents = Bitmap.new(192, 64)
window.contents.draw_text(0, 0, 192, 32, 'Encoding: ' + $KCODE, 1)
window.contents.draw_text(0, 32, 192, 32, 'Chinese:' + chinese, 1)
loop { Graphics.update; Input.update; break if Input.trigger?(Input::C) }

p chinese

Here are the results:
(click to show/hide)
(click to show/hide)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #11 on: July 28, 2012, 07:41:28 PM »
That's not RMXP being stupid there, that's the font not supporting the characters. Try "Arial Unicode MS" and/or "Arial Unicode MS Regular" and it should work.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Localization
« Reply #12 on: July 28, 2012, 08:26:20 PM »
I have tried various Unicode fonts. They seem to have no problem displaying the same exact text in various other applications, but will not work in RMXP when I use the same exact font.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #13 on: July 28, 2012, 09:16:27 PM »
RMXP was originally Japanese software, that's really odd. :/
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3247
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Localization
« Reply #14 on: July 28, 2012, 09:20:24 PM »
They are actually Chinese characters. I have yet to try Japanese.
I figured I would test with the most problematic, and if I can get that, its all good.

I still don't understand why the same text will display in one application and not RMXP, though.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: [XP] Localization
« Reply #15 on: August 01, 2012, 10:19:19 AM »
@ForeverZer0
There is nothing wrong with the font, look at this screenshot :

(click to show/hide)

I'm using english RPG Maker and the japanese characters shown up properly in console window and message window.
All I did was to change the library using RGSS103J.dll. Set my locale to japanese, that's all.
That was a text from "show text". How about variable then? look at below screenshot :

(click to show/hide)

That was from your script :

(click to show/hide)

So I think the problem is not on how RMXP draw the text, instead, how it store the text from external file.
I don't know if this help, but well, I just giving you my thoughts.
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Localization
« Reply #16 on: August 01, 2012, 10:22:12 AM »
Now we know what the update for RGSS103J.dll was for. xD
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: [XP] Localization
« Reply #17 on: August 01, 2012, 03:07:54 PM »
Showing japanese text problem has solved, but still no luck with showing japanese text from .ini file. Tried saving it into different encoding etc. The result was the text are invisible, or in random boxes.

Then I decided to do something much basic :

1. Create a plain text file encoded with UTF-8, inside the file, there are 2 lines, こんにちわ and はじめまして
2. Create a simple method to read a file and output each line using a window, save it, change the library to to RGSS103J.dll
3. Voila, the text properly extracted from .txt file and displayed properly just like the third screenshot from my last post.

Waiting for the next script update.  :)
« Last Edit: August 01, 2012, 03:14:40 PM by azdesign »
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline Rahvin

  • Trained Member
  • *
  • Posts: 12
  • LV: 0
    • View Profile
Re: [XP] Localization
« Reply #18 on: April 14, 2013, 08:29:07 PM »
Hi,

I'm new to rpg maker and I'm using VX Ace.

I really need a localization script but I do not get this one to work.
I created the localization files as mentioned in the script but the translation does not work.

The script itself seems to get called as the CurrentCulture.txt file is created automatically when testing the game.

Im using the script for example in a show_text event as following: /loc[test_item]. The output in the game is [test_item].

Can anyone please help me to get this run under VX Ace or point me to another working localization script?

Many thanks in advance!

Offline ThallionDarkshine

  • Ethereal Devastator
  • ****
  • Posts: 268
  • LV: 55
  • Gender: Male
    • View Profile
Re: [XP] Localization
« Reply #19 on: April 14, 2013, 11:46:09 PM »
In the instructions it says to use \loc[id], not /loc[id]. Try using that.