Skip to main content

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=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= and dir= 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.

Metadata

Release files for toolforge-i18n 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for toolforge-i18n 0.1.2
File Size Uploaded
toolforge_i18n-0.1.2.tar.gz 35.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for toolforge-i18n 0.1.2
File Interpreter ABI Platform
toolforge_i18n-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 60.3 kB

Release files / toolforge_i18n-0.1.2.tar.gz

Download URL toolforge_i18n-0.1.2.tar.gz
Size 35.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f19efd4001e79c40bf46df6ba7f46fabdb3c7ba06792e3b0da65655f56fe9b85
BLAKE2b-256 checksum
How to use checksums
463768c6d0309e6ce7aee68ae4c177d0678aa81c11a89f169d8bf6d2363c29f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / toolforge_i18n-0.1.2-py3-none-any.whl

Download URL toolforge_i18n-0.1.2-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6cc5299ecf39a064f38a6aba31beac455e0b999e314396f5ffe0bb04d412fc7
BLAKE2b-256 checksum
How to use checksums
78c84d82359874853cb8936ce37978ba605d605ea650849608912e81573703b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page