A library for making Toolforge tools written in Python translatable.
Project description
toolforge_i18n
toolforge_i18n is a library for making Wikimedia Toolforge tools written in Python translatable. It’s especially geared towards Flask-based tools, but should also be usable with other frameworks.
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. -
By default, support for a MediaWiki-like
?uselang=URL parameter, including?uselang=qqxto see message keys. -
Correct conversion between MediaWiki language codes and HTML language codes / IETF BCP 47 language tags; for instance,
?uselang=simpleproduces<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
See the documentation, especially the documentation for Flask tools or for non-Flask tools depending on which framework you use.
Please note that the library is still relatively new and has not been used by many tools yet. If anything is unclear or there are problems, feel free to reach out to the maintainer(s) and/or file a task on Phabricator.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toolforge_i18n-0.1.2.tar.gz.
File metadata
- Download URL: toolforge_i18n-0.1.2.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f19efd4001e79c40bf46df6ba7f46fabdb3c7ba06792e3b0da65655f56fe9b85
|
|
| MD5 |
8ce7ec7ee2a443e74c9384842e4dbfa5
|
|
| BLAKE2b-256 |
463768c6d0309e6ce7aee68ae4c177d0678aa81c11a89f169d8bf6d2363c29f9
|
File details
Details for the file toolforge_i18n-0.1.2-py3-none-any.whl.
File metadata
- Download URL: toolforge_i18n-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6cc5299ecf39a064f38a6aba31beac455e0b999e314396f5ffe0bb04d412fc7
|
|
| MD5 |
eb384301964e912603bb3b4ff90c323b
|
|
| BLAKE2b-256 |
78c84d82359874853cb8936ce37978ba605d605ea650849608912e81573703b4
|