Locale: Difference between revisions
(New page: <source lang="bash"> ls -l /usr/share/i18n/locales/ </source> It may be necessary to install support for locales? On a Debian/Ubuntu system this can be done with (or is this standard on a...) |
No edit summary |
||
Line 6: | Line 6: | ||
<source lang="bash"> | <source lang="bash"> | ||
apt-get install locales | apt-get install locales | ||
</source> | |||
Once a locale is available, you can set it in Python, for instance: | |||
<source lang="python"> | |||
>>> locale.setlocale(locale.LC_ALL, ("nl_NL", "UTF-8")) | |||
'nl_NL.UTF8' | |||
</source> | |||
If things work, the command returns a string representing the selected locale. If the given locale is not installed on your system, or if the name is given incorrectly you may see the error: | |||
<source lang="python"> | |||
Traceback (most recent call last): | |||
File "<stdin>", line 1, in <module> | |||
File "/usr/lib/python2.5/locale.py", line 478, in setlocale | |||
return _setlocale(category, locale) | |||
locale.Error: unsupported locale setting | |||
</source> | </source> |
Revision as of 23:10, 5 April 2009
ls -l /usr/share/i18n/locales/
It may be necessary to install support for locales? On a Debian/Ubuntu system this can be done with (or is this standard on all systems):
apt-get install locales
Once a locale is available, you can set it in Python, for instance:
>>> locale.setlocale(locale.LC_ALL, ("nl_NL", "UTF-8"))
'nl_NL.UTF8'
If things work, the command returns a string representing the selected locale. If the given locale is not installed on your system, or if the name is given incorrectly you may see the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/locale.py", line 478, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting