https://github.com/openuado/pylocwolowitz
Simple localization for web apps with JSON.
https://github.com/openuado/pylocwolowitz
Last synced: 5 months ago
JSON representation
Simple localization for web apps with JSON.
- Host: GitHub
- URL: https://github.com/openuado/pylocwolowitz
- Owner: openuado
- Created: 2012-10-21T18:17:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2019-02-19T15:25:28.000Z (about 6 years ago)
- Last Synced: 2024-03-26T11:37:02.514Z (about 1 year ago)
- Language: Python
- Size: 54.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: Changes
- Contributing: CONTRIBUTING.rst
Awesome Lists containing this project
README
Introduction
============
Pylocwolowitz is a port of the awesome `Locale::Wolowitz`_ module from Perl in
Python. It is a very simple text localization system, meant to be used by web
applications (but can pretty much be used anywhere).Yes, this is yet another localization system.
Pylocwolowitz works with JSON and YAML files.
Each file can serve one or more languages. When creating an instance of this
module, you are required to pass a path to a directory where your application's
JSON localization files are present. These are all loaded and merged into one
big dict, which is stored in memory. A file with only one language has to be
named **.json (where ** is the name of the language, you'd probably
want to use the two-letter ISO 639-1 code). A file with multiple language can
be call fr_and_es.json. The basic idea is to write your application in a base
language, and use the JSON files to translate text to other languages. For
example, lets say you're writing your application in English and translating it
to Spanish and Dutch... _`Locale::Wolowitz`: https://metacpan.org/module/Locale::Wolowitz
Example:
.. code-block:: python
from pylocwolowitz import Pylocwolowitz
i18n = Pylocwolowitz('./i18n')
i18n.loc('hello', 'fr')
i18n.loc('welcome {name}', 'se', {'name': 'hobbestigrou'})