Internationalization and localization tools


Locale-Sensitive Python Method

locale.setlocale(category, locale=None)

Internationalization (I18n) Method Overview

The setlocale function sets the locale for all categories to the user’s default setting (typically specified in the LANG environment variable). This function is not thread safe. If the locale is not changed thereafter, using multithreading should not cause problems.

import locale

# Default settings based on the user's environment.
locale.setlocale(locale.LC_ALL, '')

Click here for more information.

I18n Issues

Initially, when a program starts, the locale is the C locale, no matter what the user’s preferred locale is. There is one exception: the LC_CTYPE category is changed at startup to set the current locale encoding to the user’s preferred locale encoding. The program must explicitly say that it wants the user’s preferred locale settings for other categories by calling setlocale(LC_ALL, '').

Globalyzer will detect this method and report it as an I18n issue. If you have determined that the call is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.

Locale-Sensitive Python Methods

Lingoport internationalization and localization services and software