flat assembler
Message board for the users of flat assembler.

Index > Windows > multilingual app

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 18 Apr 2005, 12:33
I decided to make an app with multiple languages in such a way: i left all resources (menus, buttons, labels, etc.) without captions. And I created some files with text for all these resources in different languages. when initializing my app, i do WM_SETTEXT for everything. Is this a good way? I think it will make the initialization of my app much longer. But it also reduces the size of executable, what is good. Or maybe there are any more efficient ways to make a multiple language support for an application?
Post 18 Apr 2005, 12:33
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 25 Apr 2005, 14:00
I think that one good solution for such case would be XML. Just define yourself a file specification eg.:
Code:
<translation>
  <language>Polish</language>
  <version>1.0</version>
  <keyword="Add">Dodaj</keyword>
  <keyword="Subtract">Odejmij</keyword>
</translation>
    

Such a solution is imho good, when you want other people to create translations to their own language, but as you see it takes some place and reading such a thing is slower than reading binary format.

Another way of doing this may look like that:
Code:
1=Dodaj
2=Odejmij
    

And such a file would be named like 'polish.lng' or something like that

And the last solution that comes to my mind is using resources. You can define for example that your program would have n different strings. Than just define somewhere in program:
Code:
MAX_STRINGS = 100 ; this is the 'n'

_ADD = 1
_SUB = 2
...
POLISH = 1
ENGLISH = 2
...

        ; user picked polish language
        mov     eax, POLISH*MAX_STRINGS
        ; let's read a string for 'add'
        add     eax, _ADD
        invoke  LoadString, [hInstance], eax, ptrBuffer, sizeof.ptrBuffer

        ; user picked english language
        mov     eax, POLISH*MAX_STRINGS
        ; let's read a string for 'add'
        add     eax, _ADD
        invoke  LoadString, [hInstance], eax, ptrBuffer, sizeof.ptrBuffer
    

And in resource definition:
Code:
#define MAX_STRINGS 100

#define POLISH 1
#define ENGLISH 2

#define _ADD 1
#define _SUB 2

STRINGTABLE BEGIN
  ((POLISH*MAX_STRINGS)+_ADD), "Dodaj"
  ((POLISH*MAX_STRINGS)+_SUB), "Odejmij"
END
    


Beware! All of these examples were written ad hoc so I don't assure they'll work in a way they're shown here

EDIT: I forgot to say, that the last solution will take a lot of place, as all strings in resources are saved in utf-16, so every single chatracter will take 2 bytes
Post 25 Apr 2005, 14:00
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.