flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
JohnFound 13 Dec 2012, 08:43
The presented idea is only work-in-progress. I made some small demo, but not the whole idea is implemented yet. (The following code uses UTF-8, so switch you browser).
The idea is to have some macro that to allow definitions of the string constants in several languages: Code: Istring1 itext <EN:'Hello.'>, \ <SP:'Hola.'>, \ <DE:'Hallo.'>, \ <BG:'Здравейте.'> The strings are actually defined on the undefined data memory, so, initially they will be empty. Only place is allocated for every string, enough to contains the longest string from the language sets. The different languages strings are separated in the defined data section in separate arrays for every language. Then when you want to switch to some language, small procedure simply copy the whole language array to the real strings and the program switches to another language. For example, the below code will switch the whole program to English: Code: stdcall SetLanguage, 'EN' The attached file contains small demo application. It simply prints some text on a language depending on the command line argument. Execute it without argument to get the list of supported languages. The program is compiled for Win32, Linux and KolibriOS (not tested).
_________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||||||||||
![]() |
|
JohnFound 13 Dec 2012, 10:42
f0dder, I am not agree with your statement: "but this is so little it doesn't matter in practice". Using external strings and tools requires that the application must be designed as easy-translatable from the beginning. Also, it limits your programming methods.
The above approach makes the program translation easy, because only string constants have to be changed. It also does not adds overhead to the program. You simply use the strings as always. The source code is UTF-8 - standard enough IMHO. You only need UTF-8 compatible editor. The translation tool that I will make for Fresh IDE will allow all strings defined with "itext" macro in the project to be edited from one common place and then patched back to the source. So, we can have both - easy readable source and easy translation. |
|||
![]() |
|
revolution 13 Dec 2012, 11:34
Rather than using a copy function how about using a single master language pointer that points to a set of pointers for each string. The advantages here are
|
|||
![]() |
|
JohnFound 13 Dec 2012, 12:09
revolution, I though about this approach and rejected it, because it will need from the user to write the program in some special way (i.e. using pointers and indexes instead of simple pointers to the strings). I wanted to make the internationalization system as transparent as possible for the programmer.
|
|||
![]() |
|
revolution 13 Dec 2012, 12:20
Use macros to build the tables and pointers. The only thing you need to add is a final line to instantiate all the built tables at the end of the file.
Last edited by revolution on 13 Dec 2012, 13:14; edited 1 time in total |
|||
![]() |
|
JohnFound 13 Dec 2012, 13:04
revolution wrote: Use macros to build the tables and pointers. The only thing you need to add is a final line to instantiate all the built tables and the end of the file. I got nothing? More detailed? _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
revolution 13 Dec 2012, 13:14
|
|||
![]() |
|
JohnFound 13 Dec 2012, 14:23
Revolution, I am using this technique all the time (including the macro library discussed here). But what exactly you suggest about the internationalization problem? Imagine one program written in English only (Fresh IDE or FASMW for example). Now, how to make it to support multiply languages?
My approach makes this task very easy - You only have to edit the strings to contain the proper translation and then to insert a call to "SetLanguage" in order to switch to the new language. (well in GUI applications you maybe have to restart the application) |
|||
![]() |
|
typedef 13 Dec 2012, 14:49
Why not just load from an .ini file instead?
![]() Code: lang.ini [EN] 0000=... 0003=&Hello [FR] 0000=... 0003=&bonjour To simplify, you can then use lists to load the current locale setting in memory on start up like so: Code: invoke SetLanguage, "EN" ; load all strings for this lang-id into a list. Can be a hex number so as to avoid the compiler defining the string in the data section. ... invoke GetLocalizedString, 3 invoke CreateWindowEx, "button", eax, ... |
|||
![]() |
|
JohnFound 13 Dec 2012, 16:40
typedef, read above. It is explained why not.
![]() |
|||
![]() |
|
f0dder 13 Dec 2012, 18:11
JohnFound wrote: f0dder, I am not agree with your statement: "but this is so little it doesn't matter in practice". Using external strings and tools requires that the application must be designed as easy-translatable from the beginning. ![]() JohnFound wrote: Also, it limits your programming methods. JohnFound wrote: The above approach makes the program translation easy, because only string constants have to be changed. JohnFound wrote: It also does not adds overhead to the program. You simply use the strings as always. ![]() JohnFound wrote: The source code is UTF-8 - standard enough IMHO. You only need UTF-8 compatible editor. ![]() The project I'm working on probably has somewhat larger scope, though - I'm not sure how many languages we're currently translating to, but there's some forty languages on the target list, and we have somewhat more than 1000 strings, I believe (which is only that low because most other stuff is content-managed). But that's a web project (yes, I sold my soul for god-$). For desktop applications, I still prefer externalized localization though. There's still the argument that it's plain easier to deal with that way, especially when you need external translators, but also because it makes it possible to deploy new translations without distributing new binaries, and it also means you can reload the localization without restarting your application. Oh, and it's easier for end-users to do their own localizations that way, too ![]() _________________ ![]() |
|||
![]() |
|
AsmGuru62 13 Dec 2012, 18:37
I agree with external language strings file.
Very convenient. But I want it to be a UNICODE file. |
|||
![]() |
|
f0dder 13 Dec 2012, 18:46
AsmGuru62 wrote: I agree with external language strings file. ![]() I personally prefer UTF-8 for storage/exchange. It does mean you'll likely need to convert to an internal format, but it's (often) easier to deal with than whatever native format. Also, JohnFound, I'm not trying to be a grumpy old flaming man ![]() ![]() _________________ ![]() |
|||
![]() |
|
JohnFound 13 Dec 2012, 19:20
I am not against the external files with language packs. I know it is easier to deploy new languages and all other advantages. And when I found some way to make FASM to write files during compilation, I can make macros to directly export the string tables to the external language files, instead of data section of the program.
![]() But still IMHO, the string definitions are better to stay in the source code. (I really hate tradeoffs). I think this method can work on big projects as well. |
|||
![]() |
|
AsmGuru62 13 Dec 2012, 21:36
UNICODE for me is 16-bits per every character.
I am not sure however, how to make these files. Say, I need a file with some Japanese text -- how do I do this? |
|||
![]() |
|
f0dder 13 Dec 2012, 21:44
AsmGuru62 wrote: UNICODE for me is 16-bits per every character. AsmGuru62 wrote: I am not sure however, how to make these files. ![]() _________________ ![]() |
|||
![]() |
|
AsmGuru62 14 Dec 2012, 01:37
You want to convince me that all characters known to man will not fit into 16-bit?
|
|||
![]() |
|
LocoDelAssembly 14 Dec 2012, 02:00
JAPANESE FOR TODAY - GAKKEN wrote: 2. Kanji |
|||
![]() |
|
typedef 14 Dec 2012, 02:39
JohnFound wrote: typedef, read above. It is explained why not. But your way uses too much time and code like just like Microsoft spent 90% of their time coding security features in MS-Word ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.