locales

raw JSON →
0.0.2 verified Fri May 01 auth: no python

A Python module for multilingual solutions, providing locale detection and translation utilities. Version 0.0.2 (released 2023-11-23). Low release cadence, no updates since initial release.

pip install locales
error ModuleNotFoundError: No module named 'locales'
cause Package not installed or mistakenly referring to standard library.
fix
Run 'pip install locales' to install the PyPI package, or use 'import locale' for the standard library.
error AttributeError: module 'locales' has no attribute 'get_locale'
cause Using an older version or incorrect import path.
fix
Ensure you have version 0.0.2 installed (pip install --upgrade locales) and use 'from locales import get_locale'.
gotcha The 'locales' package (v0.0.2) is very minimal and may not be actively maintained. It might conflict with the standard library module 'locale'. Ensure your code imports from the correct package.
fix Use 'from locales import ...' and avoid naming your file locale.py.
gotcha No official documentation or detailed README; functionality is unclear beyond basic locale get/set. May lack support for full CLDR locale data or pluralization.
fix Evaluate alternative libraries like Babel (babel.pocoo.org) for production multilingual needs.

Basic usage: set and get the current locale.

from locales import get_locale, set_locale

# Set locale (e.g., 'en_US')
set_locale('en_US')

# Get current locale
current = get_locale()
print(current)  # e.g., 'en_US'