Getting Locale from the OS

View: New views
17 Messages — Rating Filter:   Alert me  

Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey all,

I have a nicely localized app.  Now I am trying get the current locale  
on Mac OS X, and I can't seem to do it. Anyone ever got this working  
with a Mac .app using AppMain.tcl?   It works fine if I run it from  
the command and do a "export LANG=zh" beforehand.

Thanks in advance...

.hc


----------------------------------------------------------------------------

As we enjoy great advantages from inventions of others, we should be  
glad of an opportunity to serve others by any invention of ours; and  
this we should do freely and generously.         - Benjamin Franklin



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 9/9/09 7:13 PM, Hans-Christoph Steiner wrote:

>
> Hey all,
>
> I have a nicely localized app.  Now I am trying get the current locale
> on Mac OS X, and I can't seem to do it. Anyone ever got this working
> with a Mac .app using AppMain.tcl?   It works fine if I run it from
> the command and do a "export LANG=zh" beforehand.
>
> Thanks in advance...
>
> .hc
>
>

 From http://wiki.tcl.tk/1197:

exec defaults read NSGlobalDomain AppleLocale


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Am Sep 9, 2009 um 8:21 PM schrieb Kevin Walzer:

> On 9/9/09 7:13 PM, Hans-Christoph Steiner wrote:
>>
>> Hey all,
>>
>> I have a nicely localized app.  Now I am trying get the current  
>> locale
>> on Mac OS X, and I can't seem to do it. Anyone ever got this working
>> with a Mac .app using AppMain.tcl?   It works fine if I run it from
>> the command and do a "export LANG=zh" beforehand.
>>
>> Thanks in advance...
>>
>> .hc
>>
>>
>
> From http://wiki.tcl.tk/1197:
>
> exec defaults read NSGlobalDomain AppleLocale


That seems to get the locale the machine is set to, rather than the  
user.  It seems to me that $tcl::mac::locale is the same as that  
value.  I found this suggestion which gets the locale of the user  
account:

http://thread.gmane.org/gmane.comp.lang.tcl.mac/5215

exec defaults read com.apple.dock loc

But that then leaves out the order of the languages that are laid out  
in the International System Preferences.  You can get the first item  
in that list by doing this, but it doesn't seem to give a proper  
locale name (pt-PT or hz-Hant), notice the dashes and not underscores.

defaults read ~/Library/Preferences/.GlobalPreferences  
AppleCollationOrder

.hc




----------------------------------------------------------------------------

Programs should be written for people to read, and only incidentally  
for machines to execute.
  - from Structure and Interpretation of Computer Programs


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Uwe Koloska :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Am Donnerstag, 10. September 2009 schrieb Hans-Christoph Steiner:
> defaults read ~/Library/Preferences/.GlobalPreferences
> AppleCollationOrder

try 'AppleLanguages' -- this gives the list of configured languages in the
right order.

Uwe


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 10, 2009, at 4:31 PM, Uwe Koloska wrote:

> Hello,
>
> Am Donnerstag, 10. September 2009 schrieb Hans-Christoph Steiner:
>> defaults read ~/Library/Preferences/.GlobalPreferences
>> AppleCollationOrder
>
> try 'AppleLanguages' -- this gives the list of configured languages  
> in the
> right order.
>
> Uwe

I saw that, but it turns out that for AppleLanguages and  
AppleCollationOrder, they don't use a proper locale format.  i.e. its  
pt-PT, zh_Hant, zh-Hans, instead of pt_PT, zh_TW, zh_ZH.  For the  
simple ones, its the same, its just like en, de, fr, etc.

.hc

----------------------------------------------------------------------------

Mistrust authority - promote decentralization.  - the hacker ethic



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by David Zolli-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le 10 sept. 2009 à 02:44, Hans-Christoph Steiner a écrit :

>> exec defaults read NSGlobalDomain AppleLocale
>
>
> That seems to get the locale the machine is set to, rather than the
> user.  It seems to me that $tcl::mac::locale is the same as that
> value.

Can you try this:

exec defaults read com.apple.dock loc

--
David Zolli
kroc@...
http://www.kroc.tk



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

smime.p7s (5K) Download Attachment

Re: Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 10, 2009, at 5:17 PM, David Zolli wrote:

> Le 10 sept. 2009 à 02:44, Hans-Christoph Steiner a écrit :
>
>>> exec defaults read NSGlobalDomain AppleLocale
>>
>>
>> That seems to get the locale the machine is set to, rather than the
>> user.  It seems to me that $tcl::mac::locale is the same as that
>> value.
>
> Can you try this:
>
> exec defaults read com.apple.dock loc

Yeah, I mentioned that earlier in the discussion.  That works per user  
session, but doesn't update between logins.  For native Mac OS X apps,  
if I change the order of the locales in the International System  
Preferences, then start an app, that app uses the settings I just  
changed, but the 'com.apple.dock loc' thing is unchanged.  I think  
that's because it just represents the locale of the Dock, so the Dock  
would have to be relaunched in order for it to be changed.

So far, com.apple.dock loc seems to provide the best experience: per-
user session.  This is a small detail, but many Mac users are picky,  
and its nice to be able to make apps behave totally natively.

.hc

----------------------------------------------------------------------------

Mistrust authority - promote decentralization.  - the hacker ethic



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Daniel A. Steffen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Hans-Christoph,

On Thu, Sep 10, 2009 at 02:44, Hans-Christoph Steiner<hans@...> wrote:
>> exec defaults read NSGlobalDomain AppleLocale
>
> That seems to get the locale the machine is set to, rather than the
> user.  It seems to me that $tcl::mac::locale is the same as that
> value.

there is no such thing as a machine locale, all locale and language
settings in Mac OS X are per-user (the default for a new user may
depend on the language chosen during OS installation however).

$tcl::mac::locale is set to the identifier of the result of
CFLocaleCopyCurrent(), that should indeed always be the same as the
NSGlobalDomain AppleLocale preference.

There seems to be some confusion between locales and languages in this
thread, these are not the same concepts and can be set independently
on Mac OS X !

for more details see:
http://developer.apple.com/mac/library/documentation/CoreFoundation/Conceptual/CFLocales/Articles/CFLocaleConcepts.html

in particular note this paragraph:
> Note that _only the setting in the Formats tab affects CFLocale properties_. The primary
> language has no influence on CFLocale properties—it only affects the user interface, not
> regional settings.

To get the user's preferred user interface languages, you should
indeed use the NSGlobalDomain AppleLocale preference, it is normal
that this array is not using locale format, since it contains
languages and not locales...

for more details see:
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPInternational/Articles/ChoosingLocalizations.html

Unfortunately we don't currently have a way to get the current tk
application's chosen interface localization from tcl, but you can get
this via a trivial extension or using Ffidl, essentially it is the
first element of
CFBundleCopyPreferredLocalizationsFromArray(CFBundleCopyBundleLocalizations(CFBundleGetMainBundle()));

Note that the chosen localization for a given application depends not
only on the user's preferred languages but also on the localizations
available for that application, make sure you specify the
localizations that you support in your Info.plist
CFBundleLocalizations key (Wish.app by default includes all the
localizations supported by msgcat in CFBundleLocalizations).

HTH

Cheers,

Daniel

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Parent Message unknown Re: Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 11, 2009, at 2:02 AM, Daniel A. Steffen wrote:

> On Fri, Sep 11, 2009 at 00:40, Hans-Christoph Steiner<hans@...>  
> wrote:
>> So far, com.apple.dock loc seems to provide the best experience
>
> note that there is no guarantee that this will work on anything other
> than your current OS release and indeed it breaks on SnowLeopard,
> there is no 'loc' key in SnowLeopard's Dock preferences...
> In general I would strongly recommend against relying on internal
> implementation details of this type, they may even change between
> major OS releases...
>
> Cheers,
>
> Daniel

Makes sense.  I'm using it as the first attempt, then it tries more  
reliable methods if it fails.  I want to support per-user locale  
settings for anyone using a computer in a computer lab.  This is a  
common arrangement in universities, and each student can set their own  
language.  So far, this is the only way I see how to do that in Tcl.

.hc

----------------------------------------------------------------------------

"Free software means you control what your computer does. Non-free  
software means someone else controls that, and to some extent controls  
you." - Richard M. Stallman



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Daniel A. Steffen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 11, 2009 at 16:48, Hans-Christoph Steiner <hans@...> wrote:
>  I want to support per-user locale settings for anyone
> using a computer in a computer lab.  This is a common arrangement in
> universities, and each student can set their own language.  So far, this is
> the only way I see how to do that in Tcl.

no, see my earlier message, use $tcl::mac::locale for the per-user
locale, the first item of NSGlobalDomain AppleLanguages for the
per-user preferred language and the first item of
CFBundleCopyPreferredLocalizationsFromArray() for the current
application's localization language.

Cheers,

Daniel

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Daniel A. Steffen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 11, 2009 at 07:36, Daniel A. Steffen
<das@...> wrote:
> To get the user's preferred user interface languages, you should
> indeed use the NSGlobalDomain AppleLocale preference

ack, of course meant to say "use the NSGlobalDomain AppleLanguages
preference", sorry

Cheers,

Daniel

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 11, 2009, at 10:55 AM, Daniel A. Steffen wrote:

> On Fri, Sep 11, 2009 at 07:36, Daniel A. Steffen
> <das@...> wrote:
>> To get the user's preferred user interface languages, you should
>> indeed use the NSGlobalDomain AppleLocale preference
>
> ack, of course meant to say "use the NSGlobalDomain AppleLanguages
> preference", sorry


"NSGlobalDomain AppleCollationOrder" does seem to provide the current  
language that is on top of the AppleLanguages list, but the problem  
there is that they aren't always proper locale formats (pt-PT, zh-
Hans, zh-Hant, etc.)

Here's my test:
- my laptop was installed in English (en_US)
- I set my user account to have "Deutsch" as the preferred language
- I am logged with "Deutsch" as the top language
- native apps are in German
- I launch my app with an embedded Wish 8.5.6
- its in English
- "puts $tcl::mac::locale" shows me "en_US"
- "NSGlobalDomain AppleLocale" is en_US
- "NSGlobalDomain AppleCollationOrder" is de
- "com.apple.dock loc" is de_DE

.hc


----------------------------------------------------------------------------

"Free software means you control what your computer does. Non-free  
software means someone else controls that, and to some extent controls  
you." - Richard M. Stallman



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Daniel A. Steffen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Hans-Christoph,

you still seem confused about the difference between locales and
languages, please read my earlier message and the documentation I
linked to:

    http://sourceforge.net/mailarchive/message.php?msg_name=d27997510909102236k23f495edgf2442b6c3e71fedc%40mail.gmail.com

On Sat, Sep 12, 2009 at 04:19, Hans-Christoph Steiner <hans@...> wrote:
> "NSGlobalDomain AppleCollationOrder" does seem to provide the current
> language that is on top of the AppleLanguages list,

no! as the name suggest, AppleCollationOrder is the language used for
collation (i.e. sorting), this is settable independently of the
preferred interface language, by the "Order for sorted lists" popup in
International preferences.

> but the problem there is
> that they aren't always proper locale formats (pt-PT, zh-Hans, zh-Hant,
> etc.)

as I have explained before, that is because these are not locale codes
but language codes. I don't understand why you expect something that
is not a locale code to be in locale format...

> Here's my test:
> - my laptop was installed in English (en_US)
> - I set my user account to have "Deutsch" as the preferred language
> - I am logged with "Deutsch" as the top language
> - native apps are in German

ok, so you set your preferred language to German, but you left your
locale at English? (again, the locale is set in the Formats tab in
International preferences, and System Preferences warns you if your
preferred language and your locale don't match)

> - I launch my app with an embedded Wish 8.5.6
> - its in English

what do you mean by "it is in English" ? the language of the default
Wish menus? those are not localized currently, the English strings are
hardcoded in the Tk source...
Patches welcome that fix this...

As explained previously, the chosen localization of an application
depends not only on the user's preferred language, but also on what
localizations are available for the given application. Moreover, the
application code has to use the right APIs to get correctly localized
strings (which Wish currently doesn't do for the built-in menu
strings)

> - "puts $tcl::mac::locale" shows me "en_US"

as expected, since you didn't change your locale...
if you set your locale to "Deutschland", this will change to "de_DE".

> - "NSGlobalDomain AppleLocale" is en_US

same information as above

> - "NSGlobalDomain AppleCollationOrder" is de

when you changed your primary language, this got automatically changed
as well, but you can set it independently as mentioned

> - "com.apple.dock loc" is de_DE

irrelevant, this is something the Dock process computed according to
some unknown internal logic based on whatever the preferred language
happened to be when the Dock process started up. The user may since
have changed their preferred language...

again, if you want the current preferred user interface language, use
the first item in the NSGlobalDomain AppleLocale preference key, which
will be 'de' in your case presumably

Note that there are legitimate configurations where the three values
of preferred language, collation order and locale are all different
and the various customization possibilities are used, e.g. see two
real examples from my accounts below.

at this point, I don't know how to explain this any more clearly,
please read the documentation I linked to for more information, I
don't have any further time to spend on this question, sorry.

Cheers,

Daniel

-------------------------

$ defaults read -g AppleLocale
en_CH
$ defaults read -g AppleCollationOrder
de
$ defaults read -g AppleLanguages
(
    "en-AU",
    en,
    gsw,
    "de-CH",
    de
)

-------------------------

$ defaults read -g AppleLocale
fr_CH
$ defaults read -g AppleCollationOrder
fr
$ defaults read -g AppleLanguages
(
    en,
    "fr-CH",
    fr
)

-------------------------

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Hans-Christoph Steiner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Sorry, I didn't mean to say what you are saying didn't make sense, I  
read the docs you sent, but they seem to overcomplicated things.  I  
guess my question was really: how do I get a Tcl/Tk app to switch  
languages like a native Mac app?  The AppleCollationOrder seems to do  
it, except giving a format that's not always usable with  
msgcat::mclocale (pt-PT, zh-Hant, etc).  Thanks for you time.

.hc

On Sep 12, 2009, at 1:59 AM, Daniel A. Steffen wrote:

> Hi Hans-Christoph,
>
> you still seem confused about the difference between locales and
> languages, please read my earlier message and the documentation I
> linked to:
>
>    http://sourceforge.net/mailarchive/message.php?msg_name=d27997510909102236k23f495edgf2442b6c3e71fedc%40mail.gmail.com
>
> On Sat, Sep 12, 2009 at 04:19, Hans-Christoph Steiner  
> <hans@...> wrote:
>> "NSGlobalDomain AppleCollationOrder" does seem to provide the current
>> language that is on top of the AppleLanguages list,
>
> no! as the name suggest, AppleCollationOrder is the language used for
> collation (i.e. sorting), this is settable independently of the
> preferred interface language, by the "Order for sorted lists" popup in
> International preferences.
>
>> but the problem there is
>> that they aren't always proper locale formats (pt-PT, zh-Hans, zh-
>> Hant,
>> etc.)
>
> as I have explained before, that is because these are not locale codes
> but language codes. I don't understand why you expect something that
> is not a locale code to be in locale format...
>
>> Here's my test:
>> - my laptop was installed in English (en_US)
>> - I set my user account to have "Deutsch" as the preferred language
>> - I am logged with "Deutsch" as the top language
>> - native apps are in German
>
> ok, so you set your preferred language to German, but you left your
> locale at English? (again, the locale is set in the Formats tab in
> International preferences, and System Preferences warns you if your
> preferred language and your locale don't match)
>
>> - I launch my app with an embedded Wish 8.5.6
>> - its in English
>
> what do you mean by "it is in English" ? the language of the default
> Wish menus? those are not localized currently, the English strings are
> hardcoded in the Tk source...
> Patches welcome that fix this...
>
> As explained previously, the chosen localization of an application
> depends not only on the user's preferred language, but also on what
> localizations are available for the given application. Moreover, the
> application code has to use the right APIs to get correctly localized
> strings (which Wish currently doesn't do for the built-in menu
> strings)
>
>> - "puts $tcl::mac::locale" shows me "en_US"
>
> as expected, since you didn't change your locale...
> if you set your locale to "Deutschland", this will change to "de_DE".
>
>> - "NSGlobalDomain AppleLocale" is en_US
>
> same information as above
>
>> - "NSGlobalDomain AppleCollationOrder" is de
>
> when you changed your primary language, this got automatically changed
> as well, but you can set it independently as mentioned
>
>> - "com.apple.dock loc" is de_DE
>
> irrelevant, this is something the Dock process computed according to
> some unknown internal logic based on whatever the preferred language
> happened to be when the Dock process started up. The user may since
> have changed their preferred language...
>
> again, if you want the current preferred user interface language, use
> the first item in the NSGlobalDomain AppleLocale preference key, which
> will be 'de' in your case presumably
>
> Note that there are legitimate configurations where the three values
> of preferred language, collation order and locale are all different
> and the various customization possibilities are used, e.g. see two
> real examples from my accounts below.
>
> at this point, I don't know how to explain this any more clearly,
> please read the documentation I linked to for more information, I
> don't have any further time to spend on this question, sorry.
>
> Cheers,
>
> Daniel
>
> -------------------------
>
> $ defaults read -g AppleLocale
> en_CH
> $ defaults read -g AppleCollationOrder
> de
> $ defaults read -g AppleLanguages
> (
>    "en-AU",
>    en,
>    gsw,
>    "de-CH",
>    de
> )
>
> -------------------------
>
> $ defaults read -g AppleLocale
> fr_CH
> $ defaults read -g AppleCollationOrder
> fr
> $ defaults read -g AppleLanguages
> (
>    en,
>    "fr-CH",
>    fr
> )
>
> -------------------------



----------------------------------------------------------------------------

"[W]e have invented the technology to eliminate scarcity, but we are  
deliberately throwing it away to benefit those who profit from  
scarcity."        -John Gilmore



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Kevin Walzer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 9/12/09 1:04 PM, Hans-Christoph Steiner wrote:
>
> Sorry, I didn't mean to say what you are saying didn't make sense, I
> read the docs you sent, but they seem to overcomplicated things. I guess
> my question was really: how do I get a Tcl/Tk app to switch languages
> like a native Mac app? The AppleCollationOrder seems to do it, except
> giving a format that's not always usable with msgcat::mclocale (pt-PT,
> zh-Hant, etc). Thanks for you time.
>
> .hc

Hans,

Perhaps this isn't helpful, but you might want to take a look at Getleft:

http://personal1.iddeo.es/andresgarci/getleft/english/

It's a well-localized Tk app that runs on the Mac and allows switching
of languages with a simple menu entry. I think it just uses msgcat, but
it's very straightforward.

--Kevin


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Bugzilla from fandom@telefonica.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> It's a well-localized Tk app that runs on the Mac and allows switching
> of languages with a simple menu entry. I think it just uses msgcat, but
> it's very straightforward.

Actually it is done with labels with a textvariable, when the user switches
the locale, the program loads the correspoding locale file into the variables
and Tk takes care of the rest.

Andres




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac

Re: Getting Locale from the OS

by Philip Aker-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-09-11, at 22:59:53, Daniel A. Steffen wrote:

> $ defaults read -g AppleLocale
> en_CH
> $ defaults read -g AppleCollationOrder
> de
> $ defaults read -g AppleLanguages
> (
>    "en-AU",
>    en,
>    gsw,
>    "de-CH",
>    de
> )


As a side-note, it's possible for locale and collation order to be as  
below (i.e. artificial but practical in some circumstances):

# defaults read -g AppleLocale;defaults read -g  
AppleCollationOrder;defaults read -g AppleLanguages;
en_US_POSIX
root
(
     en,
     de,
     fr,
     it,
     es,
     ja
)




Philip Aker
echo astwta@...@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac