Page 1 of 1

Famitracker Localization engine

Posted: Sun Nov 15, 2015 3:14 pm
by Roflo
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 :)

Re: Famitracker Localization engine

Posted: Mon Nov 16, 2015 6:55 pm
by Roflo
I'm going to provide a better example and compiled version tomorow.

Re: Famitracker Localization engine

Posted: Fri Nov 20, 2015 7:32 pm
by Roflo
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.

Re: Famitracker Localization engine

Posted: Sat Nov 21, 2015 1:04 pm
by 8BitZtunerYT
Thank you based Roflo

Re: Famitracker Localization engine

Posted: Sun Nov 22, 2015 12:12 am
by Ralph99
Added pack for Italian language.

I hope this project gets more popular... And i know this is still in beta.

Re: Famitracker Localization engine

Posted: Sun Nov 22, 2015 9:17 am
by Roflo
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.

Re: Famitracker Localization engine

Posted: Mon Mar 07, 2016 12:08 am
by Pinci
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..?)