Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Internationalization quadrant

319 views

Published on

Published in: Lifestyle, Technology, Education
  • Be the first to comment

  • Be the first to like this

Internationalization quadrant

  1. 1. The global minded programmer Andries Nieuwenhuize Quadrant software B.V. September 2012Volg @King_Software en twitter mee met #KingSoftware!
  2. 2. Agenda Awareness & pragmatic .Net implementation Case studies: 3Volg @King_Software en twitter mee met #KingSoftware!
  3. 3. Awareness Iedere programmeur is cultureel gekleurdVolg @King_Software en twitter mee met #KingSoftware!
  4. 4. Case Study 1: DNS• International Domain Name Mapping• DNS (ASCII)• quadrant.nl | bücher.de• punycode new IdnMapping() .GetAscii() – bücher > > bcher-kva .GetUnicode() – büücher > bcher-kvaa – www.münchhausen.at – www.xn—mnchhausen-9db.at Volg @King_Software en twitter mee met #KingSoftware!
  5. 5. Resumé• Learned – Globalization is more than translation – Localized assumptions are everywhere• Best Practice – Let the (.Net) Framework do the talking. – Design Localizable, do localization afterwards. Volg @King_Software en twitter mee met #KingSoftware!
  6. 6. .NET Building blocks (1/3)System.Globalization.CultureInfo3 levels : • Invariant (cultureel agnostisch) “” – lijkt een beetje op Engels • Neutral (een taal, niet gebonden tot een region) “en” • Specific (een taal binnen een bepaalde region) “en-US” Volg @King_Software en twitter mee met #KingSoftware!
  7. 7. .NET Building blocks (2/3)• Thread.CurrentThread.CurrentCulture – default culture for all classes in System.Globalization and thus affects date/time and issues such as culture-specific formatting (such as number/currency formats), parsing, and sorting.• Thread.CurrentThread.CurrentUICulture – default culture used by ResourceManagermethods and thus affects the retrieval of user interface resources such as strings and bitmaps. Volg @King_Software en twitter mee met #KingSoftware!
  8. 8. .NET Building blocks (3/3)• CultureInfo vs. RegionInfo• "{0} | {1}", c.NativeName, new RegionInfo(c.LCID).NativeName – Nederlands (Nederland) | Nederland• RegionInfo : currency• CultureInfo (remaining parts)• Resumé – CurrentCulture vs. CurrentUICulture – CultureInfo vs. RegionInfo – Invariant vs. Neutral vs. Specific Volg @King_Software en twitter mee met #KingSoftware!
  9. 9. Multilanguage with resources• Thread | CurrentUICulture• Strongly typed Volg @King_Software en twitter mee met #KingSoftware!
  10. 10. Multilanguage with resources Don’t Do • String.FormatTrans.Found string.Format(Trans.FoundTotalNu + search.getNumberfound() mberFoundOutOfTotalEntries, + Trans.Out_of search.getNumberfound(), + search.getTotalEntries(); search.getTotalEntries()); English: “Found {0} out of {1}.” “Found 4 out of 5”; Nederlands: “{0} van de {1} gevonden.” “Gevonden 4 buiten 5”; Volg @King_Software en twitter mee met #KingSoftware!
  11. 11. Case Study: Format specifiersC|D|E|F|G|N|P|R|Xvar money = 123.456m;"The money {0:C} is mine.";Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");"The money {0:C3} is mine."; Volg @King_Software en twitter mee met #KingSoftware!
  12. 12. String Collation Functions (1/3) Compare ≠ EqualsLinguistic (Equals)• IEqualityComparer<T>• (==) equality operator | "α".Equals("β")Lexicographic (Compare to)• IComparable<T>• "α".CompareTo("β") Volg @King_Software en twitter mee met #KingSoftware!
  13. 13. String Collation Functions (2/3) Culture ≠ Invariant ≠ Ordinal"Æ".Equals("AE") –[en-US] > False"Æ".Equals("AE") –[da-DK] > Falsestring.Compare("Æ“, "AE“)StringComparison.CurrentCulture [en-US]-> 0 | [da-DK]-> 1StringComparison.InvariantCulture [en-US]-> 0 | [da-DK]-> 0StringComparison.Ordinal [en-US]-> 133 | [da-DK]-> 133 Volg @King_Software en twitter mee met #KingSoftware!
  14. 14. String Collation Functions (3/3)Compare linguistic - lexicographicCurrentCulture 100% - 100% += CaseInsensitive 100% - 52%InvariantCulture 80% - 100% += CaseInsensitive 80% - 41%Ordinal 0% - 100% += CaseInsensitive 0% - ? Volg @King_Software en twitter mee met #KingSoftware!
  15. 15. DateTimeDon’t Do• Parse() • ParseExact() – ―01/02/05‖ • ToString(“d”) • Jan 2 2005 US • ―d‖ ShortDatePattern • Feb 1 2005 UK • ―D‖ LongDatePattern • ―F‖ FullDateTimePattern • Feb 5 2001 PR China – ToString(“YY/mm /dd”); Volg @King_Software en twitter mee met #KingSoftware!
  16. 16. Case Study 3: ―-20000.15‖• The number -20000.15 formatted as currency.en-GB -£20,000.15 zh-HK (HK$20,000.15) da-DK kr -20.000,15 de-AT -€ 20.000,15 es-CL -$ 20.000,15 ja-JP -¥20,000 es-AR $-20.000,15 de-DE -20.000,15 € id-ID (Rp20.000) Volg @King_Software en twitter mee met #KingSoftware!
  17. 17. Not covered• Kentekenplaten• Postcodes• Continent van een land• Solution: – Extent CultureInfo Volg @King_Software en twitter mee met #KingSoftware!
  18. 18. Conclusion• Awareness: – Be a global minded programmer!• Pragmatic – Let the (.Net) Framework do the talking! • Resources, format-specifiers, cultureInfo, invariant, ordinal. Volg @King_Software en twitter mee met #KingSoftware!
  19. 19. Consulted• http://blogs.msdn.com/b/michkap/• .NET Internationalization: The Developer’s Guide to Building Global Windows and Web Applications Guy Smith-Ferrier Volg @King_Software en twitter mee met #KingSoftware!

×