开发者

Best approach to making sure your Linux & GTK application supports i18n and localization?

开发者 https://www.devze.com 2023-01-11 20:27 出处:网络
I am interested in the \"best approach\" to making sure your Linux & GTK based application is built from the ground up to support i18n and localization with minimal amount of pain.

I am interested in the "best approach" to making sure your Linux & GTK based application is built from the ground up to support i18n and localization with minimal amount of pain.

I've always heard that localization can be a real pain point to implement, so I am wondering if there is a good guideline and/or approach that can help make i开发者_StackOverflowt as straight forward to have i18n and localization support in an application?

Here's an example guideline that I read, however this is Microsoft Windows specific... WPF Globalization and Localization Overview


Use gettext. It's the standard method of supporting I18N on Linux (and can be used on other platforms as well).

The documentation looks intimidating but it basically boils down to changing your code from:

printf("Hello World!");

to

printf(gettext("Hello World!"));

then the program xgettext will extract all the strings in gettext() into PO files which can be edited using tools like poedit


Here's a nice short tutorial on how to use gettext: A tutorial on Native Language Support using GNU gettext. It basically covers the typical workflow of using gettext. Another nice article is PHP centric:Gettext - O'Reilly Media. Google around for "gettext tutorial" and you'll probably find more.


I think you mean internationalization... If you internationalize your pgram from teh beginning, rather than later on, localization is easy.

Some things to watch out for:

  • Don't use concatenated strings.
  • Don't use concatenated strings.
  • Don't assume the adjective/noun order is the same in each language
  • Remember when you are designing your UI that other languages may be longer or shorter in general. German for example is around 1.5x longer, while Japanese and Chinese do not require the same amount of space.
  • Use a few words to get your message across. Why? Each word is going to cost you when you get your resources translated. < strings = < expense.
  • Store dates/times in UTC
0

精彩评论

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