A library for making Toolforge tools written in Python translatable.
Project description
Toolforge I18n
A work in progress library for making Wikimedia Toolforge tools written in Python+Flask translatable.
Features
-
Make your tool translatable into dozens, potentially hundreds of languages!
-
Easy integration with translatewiki.net by reusing MediaWiki message file syntax.
-
Full support for the magic words
{{GENDER:}}
and{{PLURAL:}}
, as well as for hyperlink syntax ([url text]
) and list formatting.- Note that there is no support for any other wikitext syntax; formatting in messages (e.g. bold passages) should be written in plain HTML, if it can’t be left out the message entirely (e.g. on a surrounding element in the template).
-
By default, support for a MediaWiki-like
?uselang=
URL parameter, including?uselang=qqx
to see message keys. -
Correct conversion between MediaWiki language codes and HTML language codes / IETF BCP 47 language tags; for instance,
?uselang=simple
produces<html lang="en-simple">
. -
Correct
lang=
anddir=
in the face of language fallback: messages that (due to language fallback) don’t match the surrounding markup are automatically wrapped in a<span>
with the right attributes. (Even MediaWiki doesn’t do this! Though, admittedly, MediaWiki doesn’t have the luxury of assuming that every message can be wrapped in a<span>
– many MediaWiki messages are block elements that would rather need a<div>
.) -
Includes checks to ensure all translations are safe, without unexpected elements (e.g.
<script>
) or attributes (e.g.onclick=
), to protect against XSS attacks from translations. The tests are automatically registered via a pytest plugin and also run at tool initialization time.
How to use it
The library is still a work in progress, so preferably don’t use it yet :)
but if you’re feeling adventurous, see the documentation (docs/
folder; link to follow).
License
BSD-3-Clause
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file toolforge_i18n-0.0.8.tar.gz
.
File metadata
- Download URL: toolforge_i18n-0.0.8.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c43d0d4889621cd73c9f00224459e8cdd4432236e7a70fc09f716294d35c8741 |
|
MD5 | 3b289c904d9964c39c52b389e21fee73 |
|
BLAKE2b-256 | f124c934f721e440d7c8a7cb9ab9b25531de23f38795ef36c7dba237f0cc6ec1 |
File details
Details for the file toolforge_i18n-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: toolforge_i18n-0.0.8-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57f4b9e70a627398033ce1323c549c8410c9d5eb6e2a444a6e4e91ed159ad621 |
|
MD5 | 866476512729ee0a224d82b6273fd480 |
|
BLAKE2b-256 | 4c85b5b51e5a726df2578fb462647e815cc0ef15db5a3db66ba909601088b511 |