Vista Win32 MUI Application Development - MSDN Blogs

Document Sample
Vista Win32 MUI Application Development - MSDN Blogs Powered By Docstoc
					Windows Language
Support
Multilingual Matters!




 Non-English
  Speakers                              Native English
    91.5%               Other English
                                          Speakers
                          Speakers
                                             5.1%
                            3.4%

                                                    2
Presentation Outline

  Overview in Windows international settings

  Overview of language support in Windows Vista

  Deploying Windows Vista for multilingual scenarios

  Developing Globalized Applications on Windows Vista

  Developing Win32 MUI Applications

  Q&A

                                                        3
Presentation Goals



Attendees should leave this session with:
   Familiarity with Windows multilingual functionality and related
   settings
   Familiarity with multilingual deployment options for Windows
   Vista
   Familiarity with infrastructure and APIs provided in Windows
   Vista for developing globalized applications
   Pointers to additional information and resources


Out of scope: general Windows programming concepts

                                                                     4
Assumptions


  Familiarity with the basic concepts of writing globalized
  applications.

  Familiarity with Windows Win32 application development.




                                                              5
INTERNATIONAL SETTINGS IN
WINDOWS VISTA

                            6
International Settings in Windows Vista

Control panels:
   Regional and Language Options
   Date and Time




                                          7
International Settings in Windows Vista

Date and Time:




                                          8
International Settings in Windows Vista

Regional and Language Options:
   Format: defaults for
     Number formatting
     Currency format
     Date formats
     Time formats
     Sorting
     Other user experiences
     involving user cultural
     preferences




                                          9
International Settings in Windows Vista

Regional and Language Options:
   Format: defaults for
     Number formatting
     Currency format
     Date formats
     Time formats
     Sorting
     Other user experiences
     involving user cultural
     preferences




                                          10
International Settings in Windows Vista

Regional and Language Options:
   Format: customizable defaults




                                          11
International Settings in Windows Vista

Regional and Language Options:
   Format: customizable defaults




                                          12
International Settings in Windows Vista

Regional and Language Options:
   Location




                                          13
International Settings in Windows Vista

Regional and Language Options:
   Keyboards and Languages
     Enable/disable languages for
     input & editing documents
     Select keyboard layouts or
     other input methods




                                          14
International Settings in Windows Vista

Regional and Language Options:
   Keyboards and Languages
     Enable/disable languages for
     input & editing documents
     Select keyboard layouts or
     other input methods




                                          15
International Settings in Windows Vista

Regional and Language Options:
   Keyboards and Languages
     Enable/disable languages for
     input & editing documents
     Select keyboard layouts or
     other input methods




                                          16
International Settings in Windows Vista

Regional and Language Options:
   Keyboards and Languages
     Change language for Windows
     user interface
        Not all SKUs




                                          17
International Settings in Windows Vista

Regional and Language Options:
   Administrative
     Machine-wide settings
        “System locale”
           Code page used by legacy apps
           Also impacts some font
           behaviours (font linking)




                                           18
International Settings in Windows Vista

Regional and Language Options:
   Administrative
     Machine-wide settings
        Copy to reserved accounts
           Default settings for new users




                                            19
International Settings in Windows Vista

Regional and Language Options:
   Can apply settings from command line

   control intl.cpl,, /f:"settingsfile.xml"

    <gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
         <!--User List-->
         <gs:UserList>
               <gs:User UserID="Current"/>
         </gs:UserList>

         <!--User Locale-->
         <gs:UserLocale>
               <gs:Locale Name="en-US" SetAsCurrent="true"/>
         </gs:UserLocale>
    </gs:GlobalizationServices>



   http://www.microsoft.com/globaldev/vista/vista_tools/vista_co
   mmand_line_international_configuration.mspx                  20
MULTILINGUAL SUPPORT IN
WINDOWS VISTA

                          21
Multilingual Support in Windows Vista

Various possible levels of language support
   Text display
   Editing: text display and input method(s)
     Keyboard layout or IME
   Locale
     Formats, collation, calendar
   Localization
     Partial — Complete
   Extended language functionality
     Voice: text-to-speech, speech recognition
     Handwriting recognition
     Language detection
     Word breaker, stemmer; proofing tools       22
Text-display enablement
Includes:
   Complex-script shaping support (if needed)
   Fonts (at least one)
   Font fallback
   Implemented in Win32 APIs/controls
     ExtTextOut, DrawText, User/common controls, RichEdit
May or may not get implemented:
   Dictionary-based line breaking
   Special vertical-layout behaviour
   Other frameworks (e.g. GDI+, WPF)

                                                       23
Text-display enablement: scripts
Windows XP
  Europe: Latin, Cyrillic, Greek
  W. Asia: Arabic, Armenian, Georgian, Hebrew, Syriac
  E. Asia: CJK (Simplified, Traditional, Kana, Hangul, CJK
  Extension B)
  S.E. Asia: Thai
  S. Asia: Devanagari, Gujarati, Gurmukhi, Kannada, Telugu,
  Tamil, Thaana
  Surrogates



                                                              24
Text-display enablement: scripts
Windows XP SP2
   Europe: Latin, Cyrillic, Greek
   W. Asia: Arabic, Armenian, Georgian, Hebrew, Syriac
   E. Asia: CJK (Simplified, Traditional, Kana, Hangul, CJK
   Extension B)
   S.E. Asia: Thai
   S. Asia: Bengali, Devanagari, Gujarati, Gurmukhi, Kannada,
   Malayalam, Telugu, Tamil, Thaana
   Surrogates



                                                            25
Text-display enablement: scripts
Windows XP
   CJK, “complex” scripts
   not enabled in all SKUs
   by default




                                   26
Text-display enablement: scripts
Windows Vista
   Europe: Latin, Cyrillic, Greek
   W. Asia: Arabic, Armenian, Georgian, Hebrew, Syriac
   E. Asia: CJK (Simplified, Traditional, Kana, Hangul, CJK
   Extension B), Mongolian, Yi
   S.E. Asia: Khmer, Lao, Thai
   S. Asia: Bengali, Devanagari, Gujarati, Gurmukhi, Kannada,
   Malayalam, Oriya, Sinhala, Telugu, Tamil, Thaana, Tibetan
   Americas: Cdn Aboriginal Syllabics, Cherokee
   Africa: Ethiopic
   Surrogates
                                                            27
  Text-display enablement: scripts

Oriya text with Kalinga Font   Khmer text with DaunPenh Font




Loa text with DokChampa Font   Sinhala text with Iskoola Pota Font




                                                                28
Text-display enablement: scripts
Windows Vista
   Text display for all
   scripts always enabled
   (all editions / SKUs)
     Note: some perf
     considerations




                                   29
Text-display enablement: scripts
Other enhancements:
   Enhanced font fallback for Extension B
     MingLiU vs. MingLiU_HKSCS vs. Simsun
   Uniscribe
     OpenType APIs
        Apply discretionary OpenType feature tags
                                                    Demo
        Apply OpenType language-system tags
     Performance




                                                           30
Text-display enablement: fonts
Many new fonts
   New fonts for newly-supported scripts
      Kalinga ବୁ ଧବାର        Mongolian Baiti ᠭᠠᠷᠠᠬ ᠦ᠋ᠨ ᠭᠤᠷᠪᠡᠨ
      Iskoola Pota බදාදා     Microsoft Himalaya གཟའ་ལྷག་པ།
      DaunPenh ថ្ងៃពុធ       Microsoft Yi Baiti ꆏꊂꌕ
      MoolBoran ថ្ងៃពុធ      Nyala ረቡዕ
                             Euphemia ᐱᖓᑦᓯᖅ
      DokChampa ວນພດ
                ັ ຸ          Plantagenet Cherokee ᏦᎢᏁᎢᎦ

   New “Aero”-theme UI fonts (ClearType hinting)
      Segoe UI               Meiryo すいようび
      Malgun Gothic 수요일      Microsoft JhengHei 星期三
                             Microsoft YaHei 星期三




                                                                31
Text-display enablement: fonts
Many new fonts
   New ClearType-hinted document fonts
    Calibri                         Constantia
    Cambria / Cambria Math          Corbel
    Candara                         Consolas

   Other new fonts
    Segoe Print                     SimSun-ExtB (Simp. Chinese)
    Segoe Script                    Fangsong 星期三
    Arabic Typesetting   ‫األربعاء‬   KaiTi 星期三
                                    MingLiU_HKSCS(-ExtB) 星期三
    Microsoft Uighur ‫چارشەنبە‬
                                    DFKai-SB 星期三
    Leelawadee วันพุธ




                                                                  32
Text-display enablement: fonts
Additions to existing fonts: Unicode 5.0 updates
     Arial                             Microsoft Sans Serif
     Courier New                       Tahoma
     Times New Roman




    Font                XP File Size     Vista File           XP Glyphs   Vista Glyphs
                                            Size
    Arial                 359 KB          749 KB                1680         3381
    Arial Black           115 KB           117 KB               669           674
    Arial Bold            344 KB          728 KB                1680         3381
    Arial Bold Italic     222 KB          539 KB                966          2516
    Arial Italic          203 KB          534 KB                966          2516



                                                                                    33
Text-display enablement: fonts
Overall
          Windows XP SP2             Windows Vista

          91.4 MB                   290+ MB
                                712,000+ glyphs
      218,725 glyphs
                            almost 500,000 new glyphs

                              191 fonts installed by default
          133 total fonts
                               68 new fonts, 10 removed

                                                               34
Text-display enablement: fonts
Font smoothing: ClearType selected by default




        Outline         Un-hinted       ClearType

    Tuning:
    http://www.microsoft.com/typography/ClearTypeInfo.mspx




                                                             35
Text-display enablement
Other graphics frameworks
   GDI+
     Small increase in script support:
       New: Oriya; Arabic/Hebrew/Thai OpenType
     Comparison with GDI:
       Support for ClearType hinting
       Support for TrueType-flavour OpenType fonts
       Support for OpenType fonts with embedded bitmaps
       No support for Type 1/CFF-OpenType, bitmap/vector .FON
       Unsupported scripts: Mongolian, Sinhala, Tibetan




                                                                36
Text-display enablement
Other graphics frameworks (cont’d)
   Windows Presentation Foundation (.Net 3.5)
     New text stack (.Net 3.0): managed-code shaping
     engines
     ClearType, sub-pixel glyph positioning
     Comparison with GDI
       GDI does not support sub-pixel positioning
       Support for OpenType fonts (TrueType or CFF outlines)
       No support for embedded bitmaps
       No support for Type 1, bitmap/vector .FON
       Unsupported scripts: Khmer, Old Hangul, Sinhala
                                                               37
Text-display enablement
Other graphics frameworks (cont’d)
   Windows Presentation Foundation (.Net 3.5)
     ClearType, sub-pixel glyph positioning




                                                38
Text-display enablement
Summary
   Support for scripts used by all major languages with
   broad market interest, and hundreds of lesser-known
   languages
     Most significant gap in current coverage: Myanmar
   Enablement and fonts for a large portion of Unicode
   5.0
     Many characters not covered in Vista fonts will display
     in documents using 3rd-party fonts
   Support for advanced typography
     WPF, Win32 (low-level APIs)
                                                               39
Text Input
Types of input
   Keyboard / IME
   Speech
     Speech recognition
     Text-to-speech
   Hand-writing recognition
Infrastructure
   Text Services Framework



                              40
Text Input
New keyboard layouts (non-IME)
 Assamese – INSCRIPT           Khmer                           Romanian (Programmer)
 Bashkir                       Lao                             Romanian (Standard) –
                                                               [formally Romanian in XP]
 Belgian (Period)              Lithuanian New                  Sinhala
 Bengali - INSCRIPT (Legacy)   Luxembourgish                   Sinhala - Wij 9
 Bulgarian (Latin)             Macedonian (FYROM) _ Standard   Sorbian Extended
 Bulgarian (Phonetic)          Mongolian (Mongolian Script)    Sorbian Standard
 Bulgarian (Typewriter)        Napali                          Tajik
 Georgian (Ergonomic)          Oriya                           Tibetan (PRC)
 Georgian (QWERTY)             Pashto (Afghanistan)            Turkmen
 Greenlandic                   Persian –                       Uighur
                               [formally Farsi in Windows XP
 Inuktitut –Latin              Portuguese (Brazilian ABNT2)    Ukrainian (Enhanced)
 Inuktitut –Naqitaut           Romanian (Legacy)               Yakut
                                                                                           41
Text Input
IMEs
   CJK IME enhancements
     Addition character support
       JIS 2004, Extension B
     Improved UI, dictionaries, logic
     New input modes
     IME Pad available from all IMEs
   Yi
   Amharic


                                        42
Text Input
Handwriting recognition




     Chinese (Simplified)    French     Korean
     Chinese (Traditional)   German     Portuguese
     English                 Italian    Spanish
     Dutch                   Japanese


                                                     43
Text Input
Voice
    Speech recognition
     US English                  French            German
     UK English                  Japanese          Spanish
     Chinese (Simplified)        Italian



   Text-to-speech
     US English             Chinese (Simplified)


   Installed with UI language pack
                                                             44
Locale Data
Locale: default cultural conventions (formats, etc.)
   Language / writing system / region
   35 new Vista locales
      Alsatian (France)         Amharic (Ethiopia)        Assamese (India)
      Bashkir (Russia)          Bengali (Bangladesh)      Breton (France)
      Corsican (France)         Dari (Afghanistan)        English (India)
      English (Malaysia)        English (Singapore)       Greenlandic (Greenland)
      Hausa (Nigeria)           Igbo (Nigeria)            Inuktitut (Syllabics, Canada)
      Khmer (Cambodia)          K'iche (Guatemala)        Kinyarwanda (Rwanda)
      Lao (Lao P.D.R.)          Lower Sorbian (Germany)   Mongolian (Mongolian, PRC)
      Occitan (France)          Oriya (India)             Sinhala (Sri Lanka)
      Spanish (United States)   Tajik (Tajikistan)        Tamazight (Latin, Algeria)
      Tibetan (PRC)             Turkmen (Turkmenistan)    Uighur (PRC)
      Upper Sorbian (Germany)   Wolof (Senegal)           Yakut (Russia)
      Yi (PRC)                  Yoruba (Nigeria)


   206 total locales
                                                                                          45
Locale Data
Calendars
    New: Saudi Hijri (Um Al Qura)
    Supported calendars:
      Gregorian
      Hebrew (lunar)
      Hijri
      Japanese Imperial Era
      Korean Tangun Era
      Taiwan
      Thai
      Um Al Qura (Saudi Hijri)
                                    46
UI Localization
Translate user-interface (menus, dialogs, etc) & helps
   Different levels of localization
      Language Packs for 36 SKU languages
        Full
        Partial + base language
      Language Interface Packs (LIPs)
        Most common UI only




                                                         47
UI Localization
SKU-level localization
   Windows XP: 25
    Arabic                       Finnish               Polish
    Brazilian Portuguese         French                Portuguese
                                 German
    Chinese – Simplified         Greek                 Russian
    Chinese – Traditional        Hebrew
    Chinese – Traditional (HK)   Hungarian
                                 Italian
    Czech                        Japanese              Spanish
    Danish                       Korean                Swedish
    Dutch
    English                                            Turkish
                                 Norwegian -- Bokmål




                                                                    48
UI Localization
SKU-level localization
   Windows Vista: 36
    Arabic                       Finnish               Polish
    Brazilian Portuguese         French                Portuguese
    Bulgarian                    German                Romanian
    Chinese – Simplified         Greek                 Russian
    Chinese – Traditional        Hebrew                Serbian – Latin
    Chinese – Traditional (HK)   Hungarian             Slovak
    Croatian                     Italian               Slovenian
    Czech                        Japanese              Spanish
    Danish                       Korean                Swedish
    Dutch                        Latvian               Thai
    English                      Lithuanian            Turkish
    Estonian                     Norwegian -- Bokmål   Ukrainian




                                                                         49
UI Localization
SKU languages
   Full, partial
   Multilingual User Interface
   (MUI)
      Ultimate / Enterprise edns
      User-selected UI language
      Single-image deployment
      for multiple languages




                                   50
UI Localization
Language Interface Packs (LIPs)
   Limited, common-UI (20-80 rule)
   Tied to a parent language
   60+ languages
   Afrikaans    Gujarati      Kyrgyz               Quechua
   Albanian     Hausa         Lao                  Serbian
   Amharic      Hindi         Luxembourgish        Sesotho sa Leboa
   Armenian     Icelandic     Macedonian           Setswana
   Assamese     Igbo          Malay                Sinhala
   Azeri        Indonesian    Malay                Tamil
   Basque       Inuktitut     Malayalam            Tatar
   Belarusian   Irish         Maltese              Telugu
   Bengali      isiXhosa      Maori                Urdu
   Bengali      isiZulu       Marathi              Uzbek
   Bosnian      Kannada       Nepali               Vietnamese
   Bosnian      Kazakh        Norwegian, Nynorsk   Welsh
   Catalan      Khmer         Oriya                Wolof
   Filipino     Kinyarwanda   Pashto               Yoruba
   Galician     Kiswahili     Persian
   Georgian     Konkani       Punjabi
                                                                      51
UI Localization
Obtaining language packs
   SKU languages
     ~150MB (expand to ~1GB)
     Ultimate: Vista Ultimate Extras (Windows Update)
     Enterprise: Language Pack CD-ROM
      Language of retail SKUs: availability depends on
     region
   LIP languages
     Can only be installed on parent language
     Free download
       http://www.microsoft.com/unlimitedpotential/programs/llp.mspx
                                                                       53
Other Global Features in Vista
World clocks




Indexing
   Diacritic-sensitive
     Indexing Options control Panel



                                      55
Other Global Features
International Domain Names (IDNA)




   Scam protection
     Show only IDNs that match IE language settings




                                                      56
Extensible enablement
  Text display
    Can add new fonts, but not new complex-script shaping
    engines
  Input
    Microsoft Keyboard Layout Creator (MSKLC)
      Basic layouts (no IMEs)
      http://www.microsoft.com/globaldev/tools/msklc.mspx
      Infrastructure limitation: must associate with existing
      LANGID
    3rd-party:
      IME: Yes
      Voice/handwriting: No                                     57
Extensible enablement
  Locales
   Locale Builder (Beta 2)
      Override existing locale / new custom locale
      http://go.microsoft.com/fwlink/?LinkID=96654
      Info: http://msdn.microsoft.com/en-
      us/magazine/cc163506.aspx
      Infrastructure limitation: all custom locales share single
      LANGID
  UI Language packs: not extensible



                                                                   58
DEPLOYING WINDOWS VISTA FOR
MULTILINGUAL SCENARIOS

                              59
Windows Vista Deployment
Globalization scenarios
   Create image with multiple language packs
     WDS or other deployment tools
   Create multilingual install point
   Modify language settings in an image
   Deploy a custom / replacement locale




                                               60
Windows Vista Deployment
Setup with multilingual image




                                61
Windows Vista Deployment
Tools
   Windows Automated Installation Kit (Windows AIK)
     http://www.microsoft.com/downloads/details.aspx?FamilyID=993c
     567d-f12c-4676-917f-05d9de73ada4&displaylang=en
     Package Manager: add / remove lang packs
     Intlcfg.exe: modify int’l settings
     Image Manager: create unattended-settings file




                                                                 62
Windows Vista Deployment
Create image with multiple language packs (WDS etc.)
   Copy staged image (install.wim from sources folder) to local directory
   Copy language packs (lp.cab from langpacks folder) to local directory
   Mount image
   imagex /mountrw c:\LP_Offline\Images\install.wim <imageId> c:\Mounted_Image
   Remove language pack(s)
   pkgmgr /a /up /m:c:\temp\en-US\lp.cab
   /o:c:\Mounted_Image;c:\Mounted_Image\Windows /l:c:\log-files\uninstall-en-
   US.log
   Add language pack(s)
   pkgmgr /a /ip /m:c:\lps\de-DE\lp.cab
   /o:c:\Mounted_Iimage;c:\Mounted_Image\Windows /l:c:\logs\install-de-DE.log
   Regenerate lang.ini
   intlcfg.exe –genlangini –image:c:\Mounted_Image –dist:c:\LP_Offline\Images
   Unmount image and commit changes
   imagex /unmount /commit c:\mounted_image

                                                                                63
Windows Vista Deployment
Create multilingual install point
   Create folder for distribution
   mkdir c:\windows_distribution
   Copy media contents
   Make folders for LPs in distribution and copy LPs
   mkdir C:\windows_distribution\Langpacks\de-DE
   copy d:\Langpacks\de-DE\lp.cab c:\windows_distribution\Langpacks\de-DE
   Copy Setup resources, license files for lang packs
   xcopy D:\Sources\de-DE\* c:\windows_distribution\Langpacks\de-DE /cherkyi
   Mount image
   imagex /mountrw c:\windows_distribution\Sources\install.wim <imageId>
   c:\Mounted_Image
   Regenerate lang.ini
   intlcfg.exe -genlangini -image:c:\Mounted_Image -dist:c:\windows_distribution
   –all:de-DE
   Unmount image and commit changes
   imagex /unmount /commit c:\mounted_image
                                                                               64
Windows Vista Deployment
Updating international settings
   Offline image: use intlcfg.exe
      Individual settings:
        User locale
           Also determines location
        Input locale (language / layout)
        System locale
        UI language
        UI language fallback
        Time zone
      -all:locale_name — sets to that locale (except time zone)
      -skudefaults:language — sets as in MS SKU

                                                             65
Windows Vista Deployment
Updating international settings
   During setup: use Unattend.xml
     Individual settings
        UI language
        Language fallback
        User locale
        System locale
        Input locale
        Time zone
     WinPE, specialize, OOBE phases


                                      66
Windows Vista Deployment
<?xml version='1.0' encoding='utf-8'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend"
 xmlns:ms="urn:schemas-microsoft-com:asm.v3">
   <settings pass="specialize">
   <component name="Microsoft-Windows-International-Core"
 publicKeyToken="31bf3856ad364e35" language="neutral"
 versionScope="nonSxS" processorArchitecture="x86">
      <UILanguage>ar-AR</UILanguage>
      <UILanguageFallback>fr-FR</UILanguageFallback>
      <SystemLocale>ar-AR</SystemLocale>
      <UserLocale>ar-AR</UserLocale>
      <InputLocale>0401:00000401</InputLocale>
   </component>
   <component name="Microsoft-Windows-Shell-Setup"
 publicKeyToken="31bf3856ad364e35" language="neutral"
 versionScope="nonSxS" processorArchitecture="x86">
      <TimeZone>ar-AR</TimeZone>
   </component>
   </settings>
</unattend>

                                                            67
Windows Vista Deployment
Updating international settings
   Customizing OOBE defaults: OOBE.xml
     Just sets defaults; user still selects values




                                                     68
Windows Vista Deployment
TechNet Resources
   Deployment overview:
   http://technet.microsoft.com/en-us/library/cc748937.aspx
   Step-by-step guide:
   http://technet.microsoft.com/en-us/library/cc766320.aspx
   Step-by-step — language packs & int’l settings:
   http://technet.microsoft.com/en-us/library/cc722391.aspx




                                                              69
Windows Vista Deployment
Custom/replacement locales, custom keyboard layouts
   Tools: Locale Builder / MS Keyboard Layout Creator
     Can create .msi
     No other features for network deployment




                                                        70
Windows Vista Deployment
Language packs and servicing
   GDRs/QFEs
     Same GDR/QFE for all languages
     If patch has resources, then is multilingual
        most (~80%) have no resources
        Smart: only downloads/installs languages needed
     Adding new language packs
        GDRs will be re-offered
        Recommend to add LP before servicing



                                                          71
Windows Vista Deployment
Language packs and servicing
   Service Packs
     Multilingual
        SP1: 5-language versus all-language
          English, French, German, Japanese, Spanish
          Get the right package!
          http://support.microsoft.com/kb/935791/
     All LPs updated after SP
        Can deploy updated LP before or after SP




                                                       72
DEVELOPING GLOBALIZED
APPLICATIONS ON WINDOWS
VISTA
                          73
Globalization
The ability of any feature to allow the customer to use, input, process,
store, and output in any language, independent of the language and
market of Windows.


                                          Use APIs to
         Enable your
                                          avoid hard-
         product to be
                                        coding market-
        used worldwide
                                        specific support


                         Vista has API
                        support for over
                          200 locales
Why Globalize?
Providing local experiences
     Individual users feel like the application was created just for
     them
     Scale your application to new markets without hard-coding
Avoid usability problems
     Sometimes a nuisance factor
        E.g. month, day in wrong order
     Other times a blocking issue
        E.g. actually cannot read date (different language)
Consistency across the desktop user experience
     User has a seamless experience across applications

                                                                       75
Use Unicode
Benefits
   Don’t need to manage code pages to provide broad,
   multilingual functionality
   Legacy code pages don’t cover the range of world
   languages
     Many Unicode-only locales
     Surrogate characters not supported in code pages
Use Unicode everywhere!
   Not just interfaces; all the way through


                                                        76
Use Unicode
Using Unicode
   Native code:
     Don’t use “ANSI” API calls
     “W” API calls: UTF-16
     WCHAR, LPWSTR: explicit 16-bit
     LPWSTR str = L"This is a Unicode string"
     CRT: wcscmp, wcscpy_s
   .Net: strings are Unicode by default



                                                77
Use Unicode
Using Unicode
   Conversion for code pages when necessary
     Win32:
       MultibyteToWideChar
       WideCharToMultibyte
     .Net: System.Text namespace
   Conversion for Internationalized Domain Names
     IdnToAscii
     IdnToNameprepUnicode
     IdnToUnicode

                                                   78
Use Unicode
Using Unicode
   Diagnosing the problems
     ???
           /     /
     gibberish




                             79
Displaying multilingual text
Many operations involved
  Characters to glyphs
     Surrogates
     Bidi
     Shaping, cluster analysis
     OpenType Layout (glyph transforms, positioning)
   Rasterization
     Low-res smoothing




                                                       80
Displaying multilingual text
Many operations involved
  Measuring
     Must consider complex-script behaviour
   Hit-testing (mouse-click to string position)
   Boundaries: line / word / cluster
   Caret, selection
   Font fallback
   Justification, paragraph layout



                                                  81
Displaying multilingual text
Caveats
   Don’t draw one character at a time
     Filters, text effects: get outline of entire rendered
     string



   Don’t assume non-negative “A”, “C” widths
   Don’t assume width of string = sum(width of char i)



                                                             82
Displaying multilingual text
Caveats
   Don’t assume words separated by space
   Don’t assume order of characters = order of glyphs
   Don’t assume characters:glyphs = 1
   Don’t assume characters:cluster = 1
     Don’t assume carat can go between any 2 characters
     Don’t assume any character can be selected
   Height of string may be greater than tmAscent –
   tmDescent
     Can’t assume text never bleeds outside
     clipping rectangle
                                                          83
Displaying multilingual text
Native APIs
   ExtTextOut
   DrawText
   User controls (Edit, List, etc.)
   hwndEdit = CreateWindow("EDIT", NULL, WS_CHILD|… );
   Edit_SetText() / SetWindowText()
   RichEdit control
      Use MSFTEDIT_CLASS (msftedit.dll)
   Common controls (comctl32.dll)
   hwndEdit = CreateWindow("WC_EDIT", NULL, WS_CHILD|… );


                                                            84
Displaying multilingual text
Native APIs
   Uniscribe
     ScriptStringAnalyse: high-level API used by standard
     Win32 APIs, controls
     Also several low-level APIs
   GDI+
     Font, Graphics.DrawString
     Distinct text stack from GDI, not as extensive script
     support



                                                             85
Displaying multilingual text
Native APIs
   Broad script support: all supported scripts
   Much done for free — if used correctly
      Bidi, shaping & glyph transforms
        Default OpenType features (e.g. ligatures) automatically
        applied, but not for some scripts in ETO, RichEdit
      Rasterization, smoothing
      Font fallback
        Not in Uniscribe low-level APIs
        RichEdit has different logic than other controls, APIs


                                                                   86
Displaying multilingual text
Native APIs
   Much done for free (con’t)
     Hit testing, measuring
     Boundaries
        Clusters
        Basic word-stop, line-breaking
          Thai dictionary, not for Khmer, Lao, …




                                                   87
Displaying multilingual text
Native APIs
   Points to note
     Algorithms that measure to find line-break
     opportunities: beware of performance!
        Excessive calls to shape text can result in severe perf hit
     GDI LOGFONT: lfCharset
        Legacy, related to code page
        ANSI_CHARSET = cp1252
        Use DEFAULT_CHARSET



                                                                      88
Languages and locales
Multiple concepts
   UI language
     Per-user default, fallback preferences
     Thread default, fallback preferences
   Input locale
     Language + keyboard-layout / input-method ID
     Set of enabled input locales per user
     Active input locale, per thread
   User locale — user’s default locale for formats,
   sorting, etc.

                                                      89
Languages and locales
Multiple concepts
   Thread locale — current thread locale for formats…
     Defaults to user’s setting
     Alternate can be set programmatically
   System locale
     System-wide setting
     Main purpose: code page for legacy applications
   Location — user’s location (GeoID)
APIs to obtain values for each concept
   Make sure to use the appropriate one!
                                                        90
Languages and locales
LCIDs / LANGIDs versus locale name IDs
   Original Win32: LCIDs, LANGIDs
     LCID: 32-bit, numeric locale ID
        E.g. 0x0409 = English (U.S.)
     LANGID: 16-bit, numeric ID
        Locale minus sort variations
   .Net: CultureInfo
     CultureInfo.Name: string IDs
        E.g. “en-US”
        Region-neutral cultures — e.g. “en”
   Win-32 in Vista: introducing SName (string IDs)
                                                     91
Languages and locales

                   Locale identifiers


          LCIDs                              Strings
 • Numeric values that represent     • String-based values that allow for
 sets of locale data (e.g. 0409 is   more transparent and predictable
 English – United States)            labeling of locale data (e.g. en-US
                                     is English – United States)



                                                                            92
Languages and locales
Use locale name, not LCID / LANGID
    IETF compliant
    Interoperability
    Pick up user-defined custom locales
    Pick up new Windows functionality over time
    All LCID-based APIs have equivalent name-based
    support in Vista
Existing gaps
    Input locales still expressed only in terms of LCIDs


                                                           93
Keyboard input
Caveats
   Don’t assume only one language
     User may have several languages enabled for input and
     switch between them
   Don’t assume one keyboard layout
     VK_A is not always “A”
     Not every keyboard supports VK_n
     Not every keyboard supports every character
   Don’t assume one character on every keystroke
     Use KeyPress event, not KeyUp / KeyDown

                                                         94
Keyboard input
Caveats
   Not all keyboard hardware have the same keys
     Application shortcuts
   Microsoft Keyboard Layout Creator
     User can create completely custom layout
     No limits on what characters will be input
     May step on top of your application shortcuts




                                                     95
Keyboard input
Win32
   Input locale — HKL
     32-bit integer combining LANGID and numeric input-
     method ID
       Infrastructure limitation: only part of infrastructure in
       Vista not using string IDs
     APIs
       GetKeyboardLayoutList() — enabled ILs for user
       GetKeyboardLayout() — active IL for thread
       WM_INPUTLANGCHANGEREQUEST, WM_INPUTLANGCHANGE
       — active IL for window changing
       ActivateKeyboardLayout() — set active IL for thread
                                                                   96
Keyboard input
Win32
   Get input characters
     WM_CHAR, WM_UNICHAR — key-press event
     But… IMEs, non-keyboard input-methods more
     complex
     Text Services Framework
   Recommendation: use provided controls
     Handle all lower-level input interactions, including IME




                                                                97
Locales
Combine multiple dimensions



Locale data            Language



                 Writing
                              Region
                 System

                                       98
Locales
Locale data contain many kinds of information


      Properties of        Properties of      Properties of
        language        language + region        region
    • Names of          • Calendar system   • Time zone
      languages and     • Date and time     • Currency
      regions             formats             formatting and
    • Text formatting   • Number formats      preferences
      information       • Keyboard
    • Sorting             standards
      information       • Font
                          preferences

                                                               99
Locales
Locale data: useful for
   Date formats
   Time formats
   Number formats
   Currency formats
   Sorting
   All kinds of user experiences where a customer’s
   cultural preferences matter
Location: useful for
   Region-specific content that you’d like to make
   available
   Aspects of user experience that are culture-specific
   but not linguistic in nature                           100
Locales
Rely on locale data to help create globalized experience
                Dev: My calendar app needs to support Windows users worldwide.
               Which calendars and date formats are important in different markets?



           Dev: Where are Windows users? I’ll ask Windows to tell me which locales are
                    supported by enumerating the locales on the machine.



            Windows: Here is a list of all the locales on the machine. I will give you this
              information by listing the identifiers for all the locales that I support.


        Dev: For each locale, what calendar, date formats, and month/day names are locally
         preferred so that I know what to display? I will ask for this one locale at a time by
                          passing the identifiers on your list into your API.



            Windows: Here is a list of all the information you asked for, for each locale.
                                                                                                 101
Locales
Win32 APIs (sampling):
   Enumerate available choices
     EnumSystemLocalesEx() — get list of installed /
     supported locales on current system
     EnumSystemGeoID() — get list of supported GeoIDs
     on current system
   Get settings
     GetUserDefaultLocaleName() — user’s default
     locale
     GetThreadLocale() — active locale set on thread

                                                        102
Locales
Win32 APIs (sampling):
   Set settings
     SetThreadLocale() — set active locale on thread
   Get particular data
     GetLocaleInfoEx() — get particular details for a
     given locale
     GetCalendarInfoEx() — get particular details for a
     given calendar
   Formatting
     GetDateFormatEx() — format numeric date as a date
     string using conventions for a certain culture
                                                          103
Locales — Collation
  Users expect lists of strings to come in some
  predictable order
    Preferences vary by language and culture
      “ll” in English vs. Spanish
      “I” vs. “i” vs. “İ” vs. “ı” (cf. Turkish)
    Users only know something is wrong when they can’t
    find something they expect to be there

  Machines expect lists of strings to come in some
  particular order
    Whatever order was assumed when list was first made
    will be expected later too
                                                         104
Locales — Collation
Binary vs. linguistically-appropriate: when to use which?
   “Y” (U+0059) vs. “y” (U+0079) vs. “ʏ” (U+028F)
   Ordering vs. Ordinal (identity)
      Which comes first? vs. Is that the same one?
   Use linguistically-appropriate sorting for strings
   ordered to present to users
   Use binary sorting when building indexes and want
   stability in behaviour over time



                                                            105
Locales — Collation
Binary vs. linguistically-appropriate: one comparison




                                                        106
Locales
Caveats
   Don’t hard-code particular conventions
     E.g. don’t assume particular currency
   Use globalized behaviour for presentation… but not for
   machine-readable values
     Localized presentation
     Locale-neutral concept, locale-neutral representation in storage,
     inter-process communication, etc.




                                                                         107
Locales
Caveats
   Things change!
     Countries merge, split apart, join EU…
     Governments declare new official languages
     Government change official names of countries, languages
     Languages are written in new writing system
     New calendar systems are legislated
     New currencies or currency symbols are adopted
   Don’t hard-code identifiers
   Don’t assume particular culture-specific data values

   Things in the world really do change!
                                                                108
Locales
Caveats
   User-level, things can change!
      Regional and Language Options control panel: user can customize formats
         If user overrides a value in a locale but then changes locale, customization is
         lost
      Microsoft Locale Builder
         Modify existing locales
         Create new custom locales — e.g. English (Japan), Ojibwa (Canada)
      Certain things can’t be changed
         Default code page for existing locale
         Default sort for existing locale
         Month / day strings in non-Gregorian calendars



                                                                                           109
Locales
Final thoughts: Don’t roll your own!
    We have platform APIs so that developers never need
    to think about geopolitically sensitive data.
    We service our data so you don’t have to.
    Don’t create your own solutions – it’s expensive and
    not scalable.
    If there’s something you need and we don’t provide
    it, let us know.



                                                      110
Globalizaton: DOs and DON’Ts
DO use Unicode
DON’T store data in any legacy code page
DO expect any kind of character
DON’T expect a specific character to be there
DO use platform controls
DON’T assume one character = 1 cluster = 1 glyph
DO draw / measure entire strings
DON’T use LCIDs
DO use culture names
DON’T ignore user preferences
DO use appropriate string comparisons
                                                   111
DEVELOPING WIN32 MUI
APPLICATIONS

                       112
MUI: What and Why
Past practice
   English-then-re-engineered-localization development
      Forked sources
      Costly development
      Multiple binary images to develop, deploy, service
      Inflexible, single-language product
Goals
   Reduce cost of developing, deploying, servicing
   Reduced costs, greater flexibility for customers


                                                           113
MUI: What and Why
Multilingual User Interface
   Single world-wide binary / satellite-resource model
      Single sources, build process, binary image to manage /
      maintain
   Multilingual UI options, configuration-driven
      Simpler, more flexible for customers
MUI in Windows
  Evolving since Windows 2000
  Vista: fully attained SWWB / satellite resources


                                                            114
MUI: How it works
Windows UI-language settings
   System-default UI language
   System-preferred UI language
   User-preferred UI language
     System / user settings must be installed, system
     languages
   Thread UI languages
     Up to 4 application languages
     Application UI language need not be installed as system
     languages

                                                          116
MUI: How it works
UI Language Fallback list
    Fall-back order
      Per-thread UI language
      User-preferred UI language
      System-preferred UI language
      System-default UI language
   Resource loader automatically manages resource
   satellites
      Search satellites for resource in order
      Partial localization supported
        LIP + base language
                                                    117
MUI Applications
A properly-globalized application that
    Separates localized resources into separate, inter-
    changeable packages
    Can have multiple language packages installed and in
    use
    Follows system- / user-configuration settings and
    fallback behaviour whenever possible




                                                       118
Developing Win32 MUI Apps
Some considerations
   Best user experience: consistent language
   throughout — within app, across apps/OS
   Best practice:
     Plan translation of resources carefully
     Package code, localizable resources separately
     Load resources according to OS UI language settings
     Deploy cleanly on multilingual systems




                                                           119
Developing Win32 MUI Apps
Resource technologies
   Windows MUI assumes use of Win32 resources
     Proprietary resources: follow system’s fallback list by calling
     GetThreadPreferredUILanguage()
   Common resource technologies in Windows include:
     Win32
     Registry strings
     Shell strings
     Help files
     Windows Event Log
     Group Policy
     WMI
     MFC resource DLLs
                                                                       120
Developing Win32 MUI Apps
Resource models
 Single-language      Multi-language           Satellite


       Code                 Code                   Code


                                           Language neutral file
  Resources (ja-JP)   Resources (en-US)


                       Resources (ja-JP)     Resources (en-US)



                                              Resources (ja-JP)
                                                                   121
Developing Win32 MUI Apps
Store localizable resources in satellite .mui files
   Use .rc files as before
   Use XML Resource Configuration (RC Config) file to
   specify which resources are to be stored in .mui file
   Use updated RC compiler or MUIRCT to generate .mui
   files
   Install .mui files using MUI naming conventions
   <install dir>\foo.exe
   <install dir>\en-US\foo.exe.mui
   <install dir>\ja-JP\foo.exe.mui

                                                      122
Developing Win32 MUI Apps
RC Config example
<?xml version="1.0" encoding="utf-8"?>
<localization>
   <resources>
      <win32Resources fileType="Application">
         <neutralResources>
            <resourceType typeNameId="#16" />
         </neutralResources>

         <localizedResources>
            <resourceType typeNameId="#2" itemId="5 6 7 8 9 10 11 12“
             itemName="HTML PRI" />
            <resourceType typeNameId="#4" />
            <resourceType typeNameId="#16" />
         </localizedResources>
      </win32Resources >
   </resources>
</localization>
                                                                        123
Developing Win32 MUI Apps
Workflow: localize source (.rc) versus localize PE (.exe)
  Source localization:
      Localize .rc files
      Generate MUI file:
        Build .mui with RC compiler, or
        Build PE and use MUIRCT to split off .mui from lang-
        neutral PE
   PE file localization:
      Build en PE and use MUIRCT to split off .mui from lang-
      neutral PE
      Localize .mui file
                                                               124
  Developing Win32 MUI Apps
  Workflow: source localization, RC compiler


  Source                   Compiled
               Compiler
   code                    .OBJ file


                                                   LN PE file
                                        Linker
                                                   (foo.exe)
Localization

   .RC files              Compiled LN
  .RC files
Localized                  resources
 .RC files
               RC.exe
RC Config
   file                    Compiled
                           Localized    Linker      MUI files
                           resources             (foo.exe.mui)
                                                           125
Developing Win32 MUI Apps
Workflow: source localization, MUIRCT

  Source
   code

               Compiler   Executable              LN PE File
               & Linker    (foo.exe)              (foo.exe)
                                       MUIRCT.
  .RC file
                                        exe

Localization               RC Config                MUI file
                              file               (foo.exe.mui)




                                                               126
Developing Win32 MUI Apps
Workflow: PE localization, MUIRCT

  Source
   code

             Compiler   Executable              LN PE File
             & Linker    (foo.exe)              (foo.exe)
                                     MUIRCT.
  .RC file
                                      exe

                         RC Config                MUI file
                            file               (foo.exe.mui)
                                               Localization




                                                             127
Developing Win32 MUI Apps
Loading Win32 resources
   MUI support is handled transparently
     To set application-specific language, use
     SetThreadPreferredUILanguages()
     Use existing resource-loading API calls without
     specifying language
     Use the language-neutral executable as the module
     name (not the .mui file)




                                                         128
Developing Win32 MUI Apps
Registry strings:
   Don’t store localizable strings in registry — move to a
   resource file
   Replace with language-neutral redirection strings of
   form “@<res binary>,-<res ID>”
      E.g. “@tzres.dll,-161”
   Call RegLoadMUIString()
      Redirection string parsed, resource loaded
      transparently
      Don’t call RegGetValue()!

                                                        129
Developing Win32 MUI Apps
Pre-Vista Windows: Win2000/XP/Server2003
    Down-level resource loader does not support Vista
    .mui files
      LANGID vs. language names
   Muiload.lib (Windows SDK)
      Use LoadMUILibrary() / FreeMUILibrary()
      Returns handle to appropriate language-specific
      resources




                                                        131
Q&A




      132
Thank you



            133
Heading
Level 0
   Level 1
     Level 2
        Level 3




                  134

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:34
posted:1/12/2013
language:Unknown
pages:130