开发者

How do the Delphi 2010 IDE's default control fonts work when internationalized?

开发者 https://www.devze.com 2023-01-28 10:57 出处:网络
I\'m using Delphi 2010. I\'ve written an application in English. I provide a TStringGrid that users can create a cross reference of component captions from English to their own language.

I'm using Delphi 2010.

I've written an application in English. I provide a TStringGrid that users can create a cross reference of component captions from English to their own language.

In every TForm's Create, I traverse all the form's controls (which have unique Tags), changing their Caption (or Hint) property to the user-provided translations.

This is implemented and working, at least in a handful of common Western languages like French, Italian, etc. Minor screen layout issues (wider buttons, etc.) I handle manually as they occur. I will not be using a third-party internationalization tool or Delphi's, unless I get very, VERY bad news in the answers to this question! :-)开发者_Go百科 Next time, maybe I'll use something like TsiLang (but not D2010's, which is too heavy for me...)

When I add components in the IDE, I leave the default font that the IDE assigns as-is. (It's MS Sans Serif in my locale.) What will happen when my program is run in Japan, for example? Will the Delphi RTL change the fonts of all standard components to a local font? Will that font display my default ASCII text on the components and allow display characters in their their local font in cases where they've customized? If I have code that is explicate setting fonts to MS Sans Serif, what happens?

Does the RTL change a TStringGrid to a locale language too?

If in some cases override the default MS Sans Serif with Arial (so Greek math symbols work) will that interfere with whatever happens on a Japanese system?

I save all user cross reference entries with TStringList.SaveToFile('Filename', Encoding) using this slow but adequately fast code:

 if (AllStringsList.Text <> UnicodeString(AnsiString(AllStringsList.Text))) then
    Encoding := TEncoding.UTF8 
 else 
    Encoding.Default

Is this going to work in all languages?

I save other user data in a TIniFile. How does it handle international characters?

Any links to discussion of this?


AFAIK MS Sans Serif is not a TrueType/OpenType font and doesn't support Unicode. Windows itself will map a font to the closer one if the one used in not available. Anway, if you're application has to support multiple languages is better to use a font that supports Unicode, especially when using a compiler/library that full supports Unicode like Delphi 2010.

Also I do not understand why you don't save everything in UTF (8 or 16) which will support any language, and get rid of locale issues. Delphi 2010 and Windows itself are UTF-16, going back and forth from ANSI to UTF will only slow down your code, lot of conversions happening.

Be aware, anyway, that properly localizing an application goes far beyond translating strings. You may have to change control sizes to accomodate for longer (or shorter) strings, you may have to adapt images and colors to the target culture (what is acceptable in Western one may not be in others), and you have to take into account different standards (i.e right-to-left reading and input). That's why most localizing tools work on resources, including the one in Delphi, to allow for localizing an application fully.

What you've implemented is something alike dxGetText. You can look at that library, and use it or take inspiration from it about font support.


For your component width problem (Minor screen layout issues (wider buttons, etc.) )

w := form1.canvas.TextWidth( yourcomponet.caption) //get the width of your text
yourcomponet.width := w + 30 // use 30 to make enough space

use it if your all the components in your form use the same font (if not replace form1 with the component uses your font )

for your right to left problem use

SysLocale.MiddleEast := true ;

I think thats all your problem (again windows will automatically manages some font issue , but still it is better to use a unicode supported font as defaut)

give chance for your user to assign whether the language is left to right (true or false) in your TStringGrid . so if it false use SysLocale.MiddleEast := true ;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号