Ok, so that's all. Let me know what you think please.
The main benefits I see this way are:
1) Adding new languages to a *_language.inc file is as easy as using any text editor, copy paste a line "a","b","c"... into Google Translator (if that language is supported) and paste back the result to the inc file at the right position in the array.
2) I believe this can be scripted into an automathed process to add as many languages as supported by Google or other
online services.
3) Easier to distribute plain text files and easier for contributors to edit (I think so)
4) Easier to read and mantein (imho). One file for form with all supported languages. Any one can read the line in english and translate to it's own language.
5) Easier to distribute as inc files are compiled into the executable. No need to distribute and install *.po files
6) You can change language on the fly, creating a loadLanguage() procedure to be called on creation time and at any moment the user wants to. Interesting in a country with more than one oficial language, a POS terminal shared with several operators, etc
7) add your own if you see any...
Bad things I see:
1) words are stored in arrays and data structures that consume memory resources.
2) all languages shall be loaded into memory (probably you dont need to have portuguese, chinese, dutch and arab at the same time, but yes for bilingual regions: finnish-swedish, spanish-catalan, spanish-euskara...)
3) all languages shall be kept in memory while running, at least co-oficial languages, to allow on-the-fly switching. Non required elements can be freed from the array.
4) add what you see here
Ehm... you are aware of resourcestring (https://www.freepascal.org/docs-html/current/ref/refse11.html#x23-220002.3)s? (also documented here (https://www.freepascal.org/docs-html/current/prog/progse38.html#x226-2400009.1)) You can use ObjPas.SetResourceStrings and ObjPas.SetUnitResourceStrings to roll your own storage system (as is done with the GetText unit for PO/MO files) while at the same type using the Object Pascal mechanism for this. And by studying LCLTranslator you can also hook yourself into the LCLs translation mechanism (which is also build upon the before mentioned units).
Is there a possibility to create a self-contained multilingual executable with ResourceStrings?At least with the i18n options and po-files its possible.
At least with the i18n options and po-files its possible.
https://wiki.freepascal.org/Everything_else_about_translations#Compiling_po_files_into_the_executable_and_change_language_while_running
By the way (since you ask for opinions), I don't like translations made with Google. Only a person who is a native speaker of the language and who is an user of the software can do a good translation (IMHO).
By the way (since you ask for opinions), I don't like translations made with Google. Only a person who is a native speaker of the language and who is an user of the software can do a good translation (IMHO).
It's a chicken and egg thing. No X translation, no X users. Google X translation, some X users and then feedback about better X translation :)
[off topic]
By the way, I never understood this story of chicken and egg. It seems obvious to me that to start a breeding you need a hen and a rooster. What would you do with an egg? ;)
[/off topic]
Hello!
@Raul_ES
Interesting example. I didn't know the "cvar, export, external" trick. :)
I have done something like your example (with little differences) in a project:
https://github.com/rchastain/eschecs/blob/master/source/language.pas
By the way (since you ask for opinions), I don't like translations made with Google. Only a person who is a native speaker of the language and who is an user of the software can do a good translation (IMHO).
Good luck with your project.
For one of my projects (SPINA Thyr (http://spina.sourceforge.net))
As a first step, it may be helpful to automatically detect the language of the system. If a translation for the current language is available then use it, otherwise use e.g. English.
...
And in your code you write something like
MyComponent.Caption := Msg (123);
And in your code you write something like
MyComponent.Caption := Msg (123);
And you ready to remember all your numeric codes or to check your dictionary to find needed text?