Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Externalization of strings for localisation


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-29-2007, 10:05 PM
Tirs's Avatar
Newbie
 
Join Date: May 2007
Location: Canyelles (Garraf), Catalonia, Spain
Posts: 2
Default Externalization of strings for localisation

Hello! This is an "ideas exchange" rather than a question -I'm explaining "how I do it" and I would like to know if someone came with a better idea.

After switching to version 5, I have noticed that I can have "included" files with code (the ones added via the "Tools-->Components" option).

I want to take advantage of this to write my programs in several languages, externalizing the strings much like it's usually done in Java with .properties and in many Linux programs with .po files.

What I'm doing is to put a subroutine called loadLang inside an additional code file (added via "Tools --> Components"). This subroutine contains just variable assignments, like:
Code:
lang_Welcome="Welcome to my program!"
lang_SureQuit="Are you sure you want to quit?"
...and then call this subroutine from App_Start. Of course I need to previously define all the language variables inside SUB Globals.

It's not a very elegant solution, especially because it only works at compilation time (to create executables for two different languages I have to compile for language 1, remove the additional file for language 1, add the file for language 2 instead, and compile again). That's why I throw this question to the forum:

Any better idea?

Thanks in advance!

_____
|!rs
Reply With Quote
  #2 (permalink)  
Old 05-29-2007, 10:29 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,313
Default

Hi
Iin the old forum I used a diferent solution for your Idea!
Here it is, since i couldn't find it int the old forum salvage....
Attached Files
File Type: zip teste.zip (1.1 KB, 17 views)
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 05-29-2007, 11:19 PM
Tirs's Avatar
Newbie
 
Join Date: May 2007
Location: Canyelles (Garraf), Catalonia, Spain
Posts: 2
Thumbs up

Nice idea! And then you can store the selected language in some small file or configuration parameter, and next time the user will automaticaly get the same language selected last time. Just let's add some button or menu option to allow to change it!

Hum... still, this option will leave some unneeded textfiles lying around. For a more compact solution, we can use the additional files "my style" (with variable assignment inside functions) and then select the language "your style", but instead of getting the name of the file to load, we just get a parameter to be passed to a "wrapper" function:
Code:
SUB loadLang(lang)
    IF lang='en' THEN loadLangEn
    IF lang='pt' THEN loadLangPt
    IF lang='es' THEN loadLangEs
   'etc... (fortunately there won't be that many, most of the times)
END SUB
The wrapper function would be inside the main source file, and each loadLangXX would be in its own additional file.

Why not just one big loadLang function directly loading the required language depending on the parameter instead of calling wrapped functions? Easy: because, in order to localise correctly, each language-dependent code must be in a separate file. You cannot put (for example) Portuguese and Spanish in the same file, because managing both languages simultaneously (for example, sending them for the translators to update something) is a pain. Even worse, imagine the nasty things a Western translator can accidentally do to a Japanese file, especially if he never installed the double-byte support...

Another suggestion: How about reading the default language from the registry? Now we have a nice library for that. Unfortunately, the contents of the key HKEY_LOCAL_MACHINE --> nls are quite cryptic

Well, obrigado for your idea! For sure I will use it.
_____
|!rs
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trim Spaces from Beginning and end of Strings BPak Questions & Help Needed 23 03-24-2008 07:51 PM


All times are GMT. The time now is 12:17 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0