Comparison I18N: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
Line 43: Line 43:
[[File:Numbers.JPG]] [[File:Currency.JPG]]
[[File:Numbers.JPG]] [[File:Currency.JPG]]
See: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx
See: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx
In order to run a proper I18n we shall have a short look onto the APIs already implemented in .net. Therefore you shall have a look onto the parameter settings which are available referring (http://msdn.microsoft.com/en-us/library/abeh092z.aspx). There are a lot of parameters already involved and there are some parameters mission.
A complete record of properties for the numbers, the currencies, the times and the dates, is called a CultureInfo-Class. Of course if you only want to get access to a number a NumberFormatInfo will work too, but a proper I18n contains two steps. NumberFormatInfo only knows a constructor without any parameters but CultureInfo enables to select a special “LCID” or a value of a Locale Chart (http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx). This values are a concrete realization of the RFC 4646 (http://www.ietf.org/rfc/rfc4646.txt) and a best practice concept to handle those problems.
Let us have a look to an example. The string “String strExample = "For this object you have to pay {0} until tomorrow."” contains a variable which shall be replaced by the a value “decimalValue = 1.23456m”. This can be done with a StringBuilder-Class “stringBuilder.AppendFormat(strExample, decimalValue.ToString("C"))”. If you run this code on a PC with US-American settings, you will have the result “For this object you have to pay ($1.23) until tomorrow.”. You should know that negative currency values are written in brackets in the United states. In England the result will be “For this object you have to pay -£1.23 until tomorrow.”
Problems are:
# The language and the settings of the operating system is not necessarily the language of the user.
# The CultureInfoRecord is not complete. For example there exists a smallest value of currency in any currency of the word. This value actually not handled by this record.
# The CultureInfoRecord is something restrictive. All three entries for Switzerland de-ch, fr-ch and it-ch bring out the currency as “Fr. …” and not as CHF.
# The proper choice of the CultureInfo-Settings shall be made either unique for a complete office (German Gruppenrichtlinien) or shall be handled by openpetra itself in order to avoid some conflicts.
# CultureInfo only handles the properties inside a specific language. The negative Dollar-values for example are brought out in USA correctly but in Germany we shall write  “For this object you have to pay -1.23 $ until tomorrow.”
Consequences:
# OpenPetra shall handle a subset of the LCID-references (http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx) and the decimal values seems to be the best choice.
# OpenPetra shall provide some more parameters to handle all I18n-Problems.

Revision as of 09:46, 9 December 2010

Criteria

  • easy for translators (do they need the full IDE? poedit?)
  • easy to update translations
  • easy for users to switch between UI languages; restart should be ok
  • GUI size changes (some languages need more space)
  • support asian languages
  • not only language, but also culture settings

Winforms resources

  • Example: SharpDevelop uses resource files
    • http://www.computer-books.us/csharp_3.php free book: Dissecting a C# Application - Inside SharpDevelop, Chapter 7, Internationalization (link at http://www.icsharpcode.net/OpenSource/SD/InsideSharpDevelop.aspx does not work)
    • Accessing Resources: centralized vs decentralized resource management model (PDF page 190)
    • online: they have an online translation application; it is proprietary (PDF page 194); offline: download xml file, translate, upload
    • not sure what they do about different sizes of controls; but it does resize somehow; even possible to switch language at runtime
  • http://www.codeproject.com/KB/dotnet/Localization.aspx describes 2 approaches with resource files:
    • Creating a satellite assembly for culture specific resource file and using it in the executing assembly
    • Creating a file based resource manager which enables accessing and reading a resource file from a location outside the assembly manifest

gettext

Flexible Layout vs Fixed Layout

TODO

Culture Settings

TODO: Date format etc

Numbers.JPG Currency.JPG See: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx

In order to run a proper I18n we shall have a short look onto the APIs already implemented in .net. Therefore you shall have a look onto the parameter settings which are available referring (http://msdn.microsoft.com/en-us/library/abeh092z.aspx). There are a lot of parameters already involved and there are some parameters mission.

A complete record of properties for the numbers, the currencies, the times and the dates, is called a CultureInfo-Class. Of course if you only want to get access to a number a NumberFormatInfo will work too, but a proper I18n contains two steps. NumberFormatInfo only knows a constructor without any parameters but CultureInfo enables to select a special “LCID” or a value of a Locale Chart (http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx). This values are a concrete realization of the RFC 4646 (http://www.ietf.org/rfc/rfc4646.txt) and a best practice concept to handle those problems.

Let us have a look to an example. The string “String strExample = "For this object you have to pay {0} until tomorrow."” contains a variable which shall be replaced by the a value “decimalValue = 1.23456m”. This can be done with a StringBuilder-Class “stringBuilder.AppendFormat(strExample, decimalValue.ToString("C"))”. If you run this code on a PC with US-American settings, you will have the result “For this object you have to pay ($1.23) until tomorrow.”. You should know that negative currency values are written in brackets in the United states. In England the result will be “For this object you have to pay -£1.23 until tomorrow.”

Problems are:

  1. The language and the settings of the operating system is not necessarily the language of the user.
  2. The CultureInfoRecord is not complete. For example there exists a smallest value of currency in any currency of the word. This value actually not handled by this record.
  3. The CultureInfoRecord is something restrictive. All three entries for Switzerland de-ch, fr-ch and it-ch bring out the currency as “Fr. …” and not as CHF.
  4. The proper choice of the CultureInfo-Settings shall be made either unique for a complete office (German Gruppenrichtlinien) or shall be handled by openpetra itself in order to avoid some conflicts.
  5. CultureInfo only handles the properties inside a specific language. The negative Dollar-values for example are brought out in USA correctly but in Germany we shall write “For this object you have to pay -1.23 $ until tomorrow.”

Consequences:

  1. OpenPetra shall handle a subset of the LCID-references (http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx) and the decimal values seems to be the best choice.
  2. OpenPetra shall provide some more parameters to handle all I18n-Problems.