Bo Berglund wrote:
> I am migrating an old BDS2006 application suite to XE5-XE7.
> One reason is to make it possible to display unicode texts in the GUI.
>
> We have used a language switching system where the user can switch
> language and then all of the new texts are read from a language file
> in the selected language. The language files are read as ini files
> using the TInifile class and contain text strings for each component
> on each form where the form class name is the section.
> For European languages the files are plain ASCII text files, but for
> Asian languages they are unicode.
>
> Now I hoped that if I migrate to XE5 and select a language like
> Japanese or Chinese the texts from the Unicode language files would
> show up in the GUI. But for some reason I only get unintelligible
> characters on the menus after switching to say Chinese.
Your language files probably store far-east text in double-byte
character sets (DBCS), not Unicode. Even your western language INI
files will assume a certain ANSI codepage for the stored text, and you
need to convert that to Unicode as well, if this codepage is not the
current PC's default ANSI codepage.
If you read data from your files directly into a variable of type
String you have to keep in mind that String is no longer what it was in
BDS2006. Your best bet is to read the text into a TBytes first and then
use the TEncoding class for the codepage involved to convert it to a
UTF16 String.
--
Peter Below (TeamB)
Bo wrote:
> We have used a language switching system where the user can switch
> language and then all of the new texts are read from a language file
> in the selected language. The language files are read as ini files
> using the TInifile class and contain text strings for each component
> on each form where the form class name is the section.
TIniFile uses Microsoft's PrivateProfile API, which is VERY limited in how
it reads/writes .ini files. The Ansi version of the API functions read/write
character data *as-is* as 8bit data, so you have to perform conversions to
UTF-16 manually. The Unicode version of the API functions require the file
to be encoded in the system local charset so it can convert to/from UTF-16.
In D2007 and earlier, TIniFile uses the Ansi functions, in D2009 and later
it uses the Unicode functions instead.
Consider using TMemIniFile instead of TIniFile, and then you can specify
the file's charset when reading/writing it. I would suggest using UTF-8
for the file encoding.
> For European languages the files are plain ASCII text files, but for Asian
> languages they are unicode.
All the more reason not to use TIniFile. Use TMemIniFile instead.
--
Remy Lebeau (TeamB)
On Wed, 7 Jan 2015 09:21:00 -0800, Douglas Rudd <> wrote:
>I have done that with ini files. Always worked good.
>
>In XP I had to go into Control Panel and "Install files for East Asian languages".
Exactly what I did in order to check while I used XP. Worked fine also
in D2007 (pre-unicode)
>I'm on Windows 8 now and I didn't have to do that. Maybe they are already installed.
Seems like some fonts for East Asian languages are available on my
Win7 too. I can see some of the translated texts but not in menus and
some other places.
>Do your menus work with other languages but not far eastern?
Some languages, but all of the others are Western Latin languages
(French, German, Italian, Prtuguese etc) so I could not really say.
>Are you saying you can put Russian text in a label but not Japanese?
Never tried that, we do not sell to Russia so no translation has been
made.
There is a note from our Turkish people that some of their characters
get mangled in the translation, might be an effect of not handling the
texts correctly, though. But that is not specifically a menu problem.
I have done that with ini files. Always worked good.
In XP I had to go into Control Panel and "Install files for East Asian languages". I'm on Windows 8 now and I didn't have to do that. Maybe they are already installed.
Do your menus work with other languages but not far eastern?
Are you saying you can put Russian text in a label but not Japanese?
Bo Berglund wrote:
> The language files are read as ini files
> using the TInifile class and contain text strings for each component
> on each form where the form class name is the section.
> For European languages the files are plain ASCII text files, but for
> Asian languages they are unicode.
Have you checked that reading the ini files yields the expected result?
How do you read those ini files? Can you show some code?
--
Uwe Raabe
Embarcadero MVP