Difference between revisions of "Internationalization/posix locale"

m
Line 1: Line 1:
 
[[Category:Internationalization]]
 
[[Category:Internationalization]]
  
== Summary ==
+
==Summary==
== Listing available locales ==
+
My Summary is based on article by Michael Becker (see [http://www.ijon.de/comp/tutorials/locale.html here]).This summary is more or less concerning SuSE-Linux.
== Checking for default locale ==
+
 
 +
There are differences between User-locale and C-locale. C-locale, is the local, which is only effectual in C-environment.  Outside C-environment if there is no other locale set, the C-locale is then effectual, which is called "POSIX"-locale.
 +
 
 +
With C-command <code>setlocale (LC_ALL,"")</code> one set C-locale with User-locale. So one could retrieve details about User-locale information with C-functions.
 +
 
 +
==Listing available locales==
 +
There are two directories that one could get information about locales.
 +
They are:
 +
''/usr/share/locale/''
 +
''/usr/share/i18n/''
 +
 
 +
In the first directory, the locales are binary files. So we could not need them for our purpose since i do not know how to read them for the moment.
 +
 
 +
In the second directory there are at least 2 subdirectories, with names charmaps and locales.
 +
 
 +
Shell command ''ls /usr/share/i18n/locales/'' list all the available locales.
 +
 
 +
==Checking for default locale==
 +
 
 +
With shell command "locale" one can get infomation about default locale.
 +
In C, to get details of localeone can use
 +
<code>setlocale (LC_ALL,"")
 +
localeconv()</code> 
 +
see ''manpage locale(7)'' to get more information.
 +
 
 
== Retrieving locale information ==
 
== Retrieving locale information ==
 +
C-command <code> nl_langinfo() </code>(defined in langinfo.h) one could get information about all categories. 
 +
For example, with <code> nl_langinfo(D_T_FMT)</code>, one get a pointer at a string, which in form of %a %d %b %Y %T %Z.
 +
 
== Other information ==
 
== Other information ==
 +
Using a parser one could also retrieve locale information,  about which I do not have a lot of idea.
 +
 +
Still there are C-functions to use categories.
 +
For example,
 +
<code>strftime()
 +
strptime()
 +
wcsftime()</code>
 +
for LC_TIME
 +
For another example,
 +
<code>isalnum
 +
isalpha
 +
isblank</code>
 +
and so on for LC_CTYPE.
 +
 +
For more information please read [http://www.opengroup.org/onlinepubs/007908799/xbd/locale.html local-Specification of Unix Open]

Revision as of 08:31, 3 September 2006


Summary

My Summary is based on article by Michael Becker (see here).This summary is more or less concerning SuSE-Linux.

There are differences between User-locale and C-locale. C-locale, is the local, which is only effectual in C-environment. Outside C-environment if there is no other locale set, the C-locale is then effectual, which is called "POSIX"-locale.

With C-command setlocale (LC_ALL,"") one set C-locale with User-locale. So one could retrieve details about User-locale information with C-functions.

Listing available locales

There are two directories that one could get information about locales. They are: /usr/share/locale/ /usr/share/i18n/

In the first directory, the locales are binary files. So we could not need them for our purpose since i do not know how to read them for the moment.

In the second directory there are at least 2 subdirectories, with names charmaps and locales.

Shell command ls /usr/share/i18n/locales/ list all the available locales.

Checking for default locale

With shell command "locale" one can get infomation about default locale. In C, to get details of localeone can use

setlocale (LC_ALL,"")
localeconv()

see manpage locale(7) to get more information.

Retrieving locale information

C-command nl_langinfo()(defined in langinfo.h) one could get information about all categories. For example, with nl_langinfo(D_T_FMT), one get a pointer at a string, which in form of %a %d %b %Y %T %Z.

Other information

Using a parser one could also retrieve locale information, about which I do not have a lot of idea.

Still there are C-functions to use categories. For example,

strftime()
strptime()
wcsftime()

for LC_TIME For another example,

isalnum
isalpha
isblank

and so on for LC_CTYPE.

For more information please read local-Specification of Unix Open