Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Module for multilingual solutions

Project description


Locales - module for multilingual projects

Getting Started


Locales uses only standard library json. You need to write the translations in json format

  "languages": {
      "ru": "Р СѓСЃСЃРєРёР№", "eng": "English", "sp": "EspaГ±ol"

  "messages": {
      "welcome": {
          "ru": "Добро пожаловать!",
          "eng": "Welcome!"
      "goodbye": {
          "ru": "РџРѕРєР°",
          "eng": "Goodbye",
          "sp": "AdiГіs"

Keys languages and messages required.

To generate the same file use:

import Locales



You can install Locales using pip

$ pip install locales

or download and drop to folder with your project


import Locales

loc = Locales("filename.json")
loc.set_default_lang("eng")  # Set the language by default

# Welcome!

print(loc.get("welcome", "ru"))
# Добро пожаловать!

# dict of key "goodbye"  ->  {'ru': 'РџРѕРєР°', 'eng': 'Goodbye', 'sp': 'AdiГіs'}

# returns the abbreviation(key) of the language  ->  eng


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Locales, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size Locales-0.0.2-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size Locales-0.0.2.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page