Famitracker Localization engine

Questions and information regarding the source & NSF driver.
Roflo
Posts: 292
Joined: Thu May 07, 2015 3:51 pm
Location: Germany
Contact:

Famitracker Localization engine

Postby Roflo » Sun Nov 15, 2015 3:14 pm

A time ago I decided to write a localization 'engine' that requires nearly no changes in the famitracker code itself. It is highly customizable by any user. It is fairly simple:
On startup common controls (static, listbox, listview, r/o edit), menus and windows are subclassed; as soon as the text of a label/menu item is changed or an item is added to a listbox etc., the 'engine' will transparently change anything matching the pattern $!identifier$ with a string taken from a selected language pack.
Language packs can be either loaded from a selected directory or from resource (i.e. using it as the default pack) and can be changed on the fly. Below there's a short introduction. A fully buildable source can be found here (press 'F5' or the stop button to change the language; quite ridiculous for now :p)


Firstly it's necessary to globally #define the symbol YFW_WINDOWS_LOCALE_FAMITRACKER in the project settings. Btw the 'engine's' main code resides in langpack.hpp/.cpp
On startup (InitInstance(), wherever) the 'engine' needs to be initialized (i.e. perfoming the subclassing):

Code: Select all

//anything is in namespace YFW::Windows::Locale::GuiLocalizer as I might use it in private...
YFW::Windows::Locale::GuiLocalizer::InitializeInstance();
//and of course at the end:
YFW::Windows::Locale::GuiLocalizer::ReleaseInstance();


Instantiate LanguagePackSystem, which holds and caches packs, somewhere.
Then select a directory where packs can be found. Language pack files start with a prefix and a suffix; the name in between is taken as the name of the pack.
Ascii, UTF8, UTF16LE and UTF16BE are supported.

Code: Select all

LanguagePackSystem ps;
ps.setLocation(u"lang", u"lang_", u".txt"); //searches for 'lang_*.txt' in directory ./lang, taking * as the name


Storing packs as resource is also possible:

Code: Select all

YFW::Windows::Locale::LanguagePack &lp = ps.AddPack(); //add empty pack
lp.setName(u"Espa\u00F1a"); //set it's name
lp.LoadResourcePack(IDR_LANGPACK1, u"langpack"); //load from resource


After this is done, the language may be freely changed. Labels, Listboxes, Menus etc. are updated:

Code: Select all

YFW::Windows::Locale::GuiLocalizer::getInstance().ChangeLanguage(ps.RequestPack(u"English")); //load/fetch from cache and set it


Of course this needs the resource file to be updated accordingly. Is is also possible to place the pattern above as a MessageBox' text or even use it in file dialogs.
If someone of the Ft developers are interested in, post a comment below :)

Roflo
Posts: 292
Joined: Thu May 07, 2015 3:51 pm
Location: Germany
Contact:

Re: Famitracker Localization engine

Postby Roflo » Mon Nov 16, 2015 6:55 pm

I'm going to provide a better example and compiled version tomorow.

Roflo
Posts: 292
Joined: Thu May 07, 2015 3:51 pm
Location: Germany
Contact:

Re: Famitracker Localization engine

Postby Roflo » Fri Nov 20, 2015 7:32 pm

I updated the code and attached a basic compiled example, which covers some of the menu bar, edit frame and status bar (notice the 'language' section in the menu bar). It includes additional packs for german, (google translate)french and (google translate)japanese.
Attachments
famitracker_lc.zip
(1.33 MiB) Downloaded 63 times

8BitZtunerYT
Posts: 379
Joined: Thu Apr 23, 2015 7:20 pm
Location: Somewhere stuck in Winamp

Re: Famitracker Localization engine

Postby 8BitZtunerYT » Sat Nov 21, 2015 1:04 pm

Thank you based Roflo
slowly ceasing to exist.
"8BitZ caresses his keyboard as he orgasms to the sounds of Winamp."
-retrodpc, 2015

User avatar
Ralph99
Posts: 149
Joined: Sun Jun 21, 2015 9:12 pm
Location: Rome, Italy
Contact:

Re: Famitracker Localization engine

Postby Ralph99 » Sun Nov 22, 2015 12:12 am

Added pack for Italian language.

I hope this project gets more popular... And i know this is still in beta.
Attachments
famitracker-lc.zip
Saluti dall'Italia! :)
(1.3 MiB) Downloaded 47 times
Ciao a tutti! :)
YouTube Account

Roflo
Posts: 292
Joined: Thu May 07, 2015 3:51 pm
Location: Germany
Contact:

Re: Famitracker Localization engine

Postby Roflo » Sun Nov 22, 2015 9:17 am

My intentional idea is to get jsr (or hertzdevil) to integrate this into current famitracker. This way it is easy (or more easily than with resource hacking :)) for users to add packs in their language, and then maybe publish it publically so it is taken into the official version of famitracker.

User avatar
Pinci
Posts: 1
Joined: Sun Mar 06, 2016 11:47 pm
Location: Chile
Contact:

Re: Famitracker Localization engine

Postby Pinci » Mon Mar 07, 2016 12:08 am

Added Spanish Pack

I hope this feature gets into Famitracker, it's pretty nice for people who don't know english or don't understand it properly.

(Also I recently noticed the old forum isn't being used anymore, I wonder why..?)
Attachments
famitracker-lc.zip
(1.33 MiB) Downloaded 30 times


Return to “Source and development”

Who is online

Users browsing this forum: No registered users and 2 guests