i18n library for Python

General chitchat, advertisements for other services, and other non-Cantr-related topics

Moderators: Public Relations Department, Players Department

User avatar
Greek
Programming Dept. Member/Translator-Polish
Posts: 4726
Joined: Mon Feb 13, 2006 5:41 pm
Location: Kraków, Poland
Contact:

i18n library for Python

Postby Greek » Thu Jan 28, 2016 9:32 pm

It's probably my first post on this forum, so hello.

As a part of my drift towards Python, I've created a Python library to handle i18n in a better way than usually used solutions based on gettext.
I'm posting it here because it's based on my experience with custom Cantr's translation engine, which was a very fun thing to work with, containing some of advanced features that aren't available for most of different libraries (e.g. nested tags).
It was also inspired by Rails i18n, but it's not any kind of port.
I've implemented all advanced features which I thought can be useful, but to keep it simple for programmers and translators.

It offers:
- translation of texts based on tag key-value pairs (like in Cantr)
- variable interpolation
- support for inner (nested) tags
- advanced fallback mechanism in case some text is not translated to a target language
- tag variants (supporting cases, numbers and genders which are very important in many languages)
- decorators to modify tag text (e.g. capitalize it)
- conditional statements
- numbers, dates and time localization (locale-based formatting)
- ability to dynamically generate tag values by a python function (when something can't be done in any other way)
In short, I'd be happy to have a library of similar functionality in Cantr.


I've kept it unfinished for quite a long time, but a month ago I've finally decided to learn how to manage python packages and publish it on PyPI.

It's hard to explain the functionality, so I think it's better to show some examples in:
project's readme - https://github.com/GreeKpl/pyslate
translator documentation - http://pyslate.readthedocs.org/en/latest/user-guide.html
and advanced examples - http://pyslate.readthedocs.org/en/latest/advanced-examples.html

Package on PyPI: https://pypi.python.org/pypi/pyslate/
‘Never! Run before you walk! Fly before you crawl! Keep moving forward! You think we should try to get a decent mail service in the city. I think we should try to send letters anywhere in the world! Because if we fail, I’d rather fail really hugely’

Return to “Non-Cantr-Related Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest