Localization Issue

  • I am referring to Technical Q&A QA1391. There apple has provided
    following code:

    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    NSArray * languages = [defaults objectForKey:@"AppleLanguages"];
    NSLog(@"%@\n", languages);

    Apple also mentions that this will give different output on different
    OS. My application runs on 10.3+, 10.4+ & 10.5+ OS. I run the above
    code on these OS & found that on 10.3.7, for traditional chinese
    language, above code retuns zh_TW while on 10.4 & 10.5 it returns zh-
    Hant. My requirement is there any API by which I can get older
    canonical form (like zh_TW) from new canonical form (like zh-Hant)?

    Please reply.

    Regards,
    Parag Vibhute
    echo <alclr.qzcefyptyqzepns...> | tr a-z@. p-za-o.@
  • There is no way to go from the newer form to the older form. You can
    use CFLocaleCreateCanonicalLanguageIdentifierFromString to go from the
    older forms to the preferred version (on 10.4 or later). If you're
    running on 10.3, that API is not available.

    You can also use APIs on NSBundle/CFBundle to avoid having to do this
    canonicalization yourself. That's the best option.

    Deborah Goldsmith
    Internationalization, Unicode Liaison
    Apple Inc.
    <goldsmit...>

    On Dec 24, 2007, at 4:59 AM, parag vibhute wrote:

    > I am referring to Technical Q&A QA1391. There apple has provided
    > following code:
    >
    > NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    > NSArray * languages = [defaults objectForKey:@"AppleLanguages"];
    > NSLog(@"%@\n", languages);
    >
    > Apple also mentions that this will give different output on
    > different OS. My application runs on 10.3+, 10.4+ & 10.5+ OS. I run
    > the above code on these OS & found that on 10.3.7, for traditional
    > chinese language, above code retuns zh_TW while on 10.4 & 10.5 it
    > returns zh-Hant. My requirement is there any API by which I can get
    > older  canonical form (like zh_TW) from new canonical form (like zh-
    > Hant)?
    >
    > Please reply.
    >
    > Regards,
    > Parag Vibhute
    > echo <alclr.qzcefyptyqzepns...> | tr a-z@. p-za-o.@
  • On Jan 2, 2008, at 1:46 PM, Deborah Goldsmith wrote:

    > There is no way to go from the newer form to the older form. You can
    > use CFLocaleCreateCanonicalLanguageIdentifierFromString to go from
    > the older forms to the preferred version (on 10.4 or later). If
    > you're running on 10.3, that API is not available.
    >
    > You can also use APIs on NSBundle/CFBundle to avoid having to do
    > this canonicalization yourself. That's the best option.

    Yes, this is a good illustration of why you usually don't want to use
    the AppleLanguages default directly.  You can use
    CFBundleCopyPreferredLocalizationsFromArray() and
    CFBundleCopyLocalizationsForPreferences() to do most of what you might
    want to do with the contents of this default, without having to deal
    with canonicalization issues, and you automatically get to match the
    standard CFBundle behavior.

    Douglas Davidson
  • Thanks for reply.

    You both have mentioned terms "canonicalization" & I also have read this in
    API reference but I have not understood what does this term means. Can you
    please explain this?

    Thanks,
    Parag

    On Jan 3, 2008 5:09 AM, Douglas Davidson <ddavidso...> wrote:

    >
    > On Jan 2, 2008, at 1:46 PM, Deborah Goldsmith wrote:
    >
    >> There is no way to go from the newer form to the older form. You can
    >> use CFLocaleCreateCanonicalLanguageIdentifierFromString to go from
    >> the older forms to the preferred version (on 10.4 or later). If
    >> you're running on 10.3, that API is not available.
    >>
    >> You can also use APIs on NSBundle/CFBundle to avoid having to do
    >> this canonicalization yourself. That's the best option.
    >
    > Yes, this is a good illustration of why you usually don't want to use
    > the AppleLanguages default directly.  You can use
    > CFBundleCopyPreferredLocalizationsFromArray() and
    > CFBundleCopyLocalizationsForPreferences() to do most of what you might
    > want to do with the contents of this default, without having to deal
    > with canonicalization issues, and you automatically get to match the
    > standard CFBundle behavior.
    >
    > Douglas Davidson
    >
    >

    --

    There are many things in your life that will catch your eye but only a few
    will catch your heart....pursue those'.
  • http://en.wikipedia.org/wiki/Canonicalization

    Deborah Goldsmith
    Internationalization, Unicode Liaison
    Apple Inc.
    <goldsmit...>

    On Jan 2, 2008, at 10:36 PM, parag vibhute wrote:

    > Thanks for reply.
    >
    > You both have mentioned terms "canonicalization" & I also have read
    > this in API reference but I have not understood what does this term
    > means. Can you please explain this?
    >
    > Thanks,
    > Parag
    >
    > On Jan 3, 2008 5:09 AM, Douglas Davidson <ddavidso...> wrote:
    >
    > On Jan 2, 2008, at 1:46 PM, Deborah Goldsmith wrote:
    >
    >> There is no way to go from the newer form to the older form. You can
    >> use CFLocaleCreateCanonicalLanguageIdentifierFromString to go from
    >> the older forms to the preferred version (on 10.4 or later). If
    >> you're running on 10.3, that API is not available.
    >>
    >> You can also use APIs on NSBundle/CFBundle to avoid having to do
    >> this canonicalization yourself. That's the best option.
    >
    > Yes, this is a good illustration of why you usually don't want to use
    > the AppleLanguages default directly.  You can use
    > CFBundleCopyPreferredLocalizationsFromArray() and
    > CFBundleCopyLocalizationsForPreferences() to do most of what you might
    > want to do with the contents of this default, without having to deal
    > with canonicalization issues, and you automatically get to match the
    > standard CFBundle behavior.
    >
    > Douglas Davidson
    >
    >
    >
    >
    > --
    >
    > There are many things in your life that will catch your eye but only
    > a few will catch your heart....pursue those'.
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today