Showing posts with label localization. Show all posts
Showing posts with label localization. Show all posts

WP7: How to Localize you DatePicker


  1. Create your DatePicker application described in this article or your own application.
  2. Insert in MainPage.xaml.cs
    using System.Globalization;
    using System.Threading;
    
  3. Windows Phone supports the display languages you may find here
  4. Next code fragment do all you need (of course you must choose "Culture code" you need):
    public MainPage()
    {
        CultureInfo newCulture = new CultureInfo("en-GB");
        Thread.CurrentThread.CurrentCulture = newCulture;
        Thread.CurrentThread.CurrentUICulture = newCulture;
    
        ...
    }
    
  5. But if your language not supported by windows phone?
    public MainPage()
    {
        CultureInfo newCulture = new CultureInfo("en-GB");
    
        //change format of DatePicker to you own format
        newCulture.DateTimeFormat.ShortDatePattern = "d/MMM/yyyy";
    
        //set day names
        newCulture.DateTimeFormat.DayNames = new string[] { "first day", 
                                                            "second day", 
                                                            "third day", 
                                                            "4 day", 
                                                            "5 day", 
                                                            "6 day", 
                                                            "7 day" };
    
        //set month names
        newCulture.DateTimeFormat.MonthNames = new string[] {"1 month", 
                                                             "2 month", 
                                                             "3 month", 
                                                             "4 month", 
                                                             "5 month", 
                                                             "6 month", 
                                                             "7 month", 
                                                             "8 month", 
                                                             "9 month", 
                                                             "10 month", 
                                                             "11 month", 
                                                             "12 month", 
                                                             ""};
    
        Thread.CurrentThread.CurrentCulture = newCulture;
        Thread.CurrentThread.CurrentUICulture = newCulture;
    
        ...
    }
    
  6. Enjoy

How to create additional localization on your iOS app - Files (plist, ...)

 1. Create a directory under project directory (in Finder) in format: language_region.lproj or language.lproj

languages list: ISO 639-2 Language Codes
regions list: ISO - Maintenance Agency

2. Right click on "Resource" in xCode project.
         Add ->
         New File ->
         Choose "Other" from Mac OS X ->
         Choose "Empty File" ->
         Next ->
         In "File Name" field change from "untitle" to "MyFileName.MyExtention" (usually Localizable.strings or MyFileName.plist) ->
         In "Location" field choose language_region.lproj folder you created ->
         Finish

3. Fill file with content do you want (copy/paste or replace file in Finder)