How to "localize" (translate) your program - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13) +---- Thread: How to "localize" (translate) your program (/showthread.php?tid=540) |
How to "localize" (translate) your program - boriel - 04-26-2013 Yes, we are in the information era, Internet was a dream in the 80s, but a reality nowadays 8) And we are in sort of Babel tower here. This tutorial proposes a simple but effective way to make your program multilingual. Needless to say 48Kb (actually less than 40Kb) are too little room to store all localized program texts simultaneously. My proposal is simply a structure to make our programs easily translatable to other languages. Here we go: ZXBASIC allows commandline defines now (1.2.3-s1022), so it's possible to do something like this: FILE: LOCALIZE.BAS This file will include the desired language Code: #ifndef LANG FILE: ENGLISH.BAS This defines strings in English, using #define directive Code: ' Just HELLO WORLD This defines strings in Spanish, using #define directive Code: ' Just HELLO WORLD A demo example, which will be localized. Code: #include <localize.bas> Code: zxb -TaB -o hello_en.tzx -D LANG=en hello.bas Code: zxb -TaB -o hello_es.tzx -D LANG=es hello.bas
We all are different native-language speakers here, so if we open-source or .bas listings, some of us would be willing to translate into our mother tongue. What do you think of this proposal? Re: How to "localize" (translate) your program - LCD - 05-01-2013 I suppose, it is possible to define multiple macros, right? -D LANG=de -D VERSION=hard -D RATING=adult Re: How to "localize" (translate) your program - boriel - 05-01-2013 LCD Wrote:I suppose, it is possible to define multiple macros, right?Yes, or that's the idea. Note this is currently *beta* in 1.3.0. The next version will have it more tested, since macros now allows also #if directives. e.g. Code: #if LANG==de && VERSION==hard || RATING=adult Re: How to "localize" (translate) your program - LCD - 05-02-2013 boriel Wrote:LCD Wrote:I suppose, it is possible to define multiple macros, right?Yes, or that's the idea. Oh, that is great and I can imagine some uses for it, apart from Languages. So this is C Plusplus syntax... I think, I will try to use it without splitting into multiple sources: Code: #ifndef LANG Re: How to "localize" (translate) your program - boriel - 05-02-2013 LCD Wrote:Oh, that is great and I can imagine some uses for it, apart from Languages.Right! But if you plan to give the lang source to other people to translate to their native language, I think it would be better to give them only a separated translation include file (e.g. because you don't want to give them the complete source). Re: How to "localize" (translate) your program - LCD - 05-02-2013 boriel Wrote:Right!In this case you are absolutly right... Re: How to "localize" (translate) your program - JBGV - 05-06-2013 boriel Wrote:What do you think of this proposal? It is a very good idea ! Translation is a headache for me :oops: Re: How to "localize" (translate) your program - cheveron - 05-29-2014 Just a couple of things to throw out there. As well as language specific strings, ZXodus uses language specific compression code (digraphs) and character sets. Re: How to "localize" (translate) your program - boriel - 05-30-2014 cheveron Wrote:Just a couple of things to throw out there. As well as language specific strings, ZXodus uses language specific compression code (digraphs) and character sets.You could also use conditional #ifdef directives, for example, and use #incbin with them. |