It is probably a better solution than have it in an array like lang(0) = "quit" and lang(300) = "terminar" and 3XX being the Portuguese, 200 the Geramany and so on. And that would be a huge hard work too. If you start building you language "include" when you start programming, it is not so bad.
Anyhow, thaks to this post
http://www.purebasic.fr/english/viewtop ... structures
I found a way to copy structures. Here is the code:
Code: Select all
Structure Language
Quit.s
Save.s
Save_as.s
Close.s
Failed.s
EndStructure
en.Language
en\Quit = "Quit"
en\Save = "Save"
en\Save_as = "Save as"
en\Close = "Close"
en\Failed = "Failed"
pt.Language
pt\Quit = "Terminar"
pt\Save = "Guardar"
pt\Save_as = "Guardar como"
pt\Close = "Fechar"
pt\Failed = "Falhou"
lang.Language
CopyMemory(@en, @lang, SizeOf(Language))
MessageRequester("", "Quit in English: " + lang\Quit)
CopyMemory(@pt, @lang, SizeOf(Language))
MessageRequester("", "Quit in Portuguese: " + lang\Quit)
You define the language structures, and use the default lang structure. At the beguining of the App, according to user choice, you copy the right structure to the default. Seems easy to me, and will give me the same hard work as using an array.
P.S. If you could have multy dimension arrays like in PHP, like this:
language ['en'] ['quit'] = "Quit"
language ['pt'] ['quit'] = "Terminar"
This would be easier, but still a lot of work... You will have to write the messages two, three, four times depending how many languages you will offer to your customer. same work no matter the method you choose