Skip to main content

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= 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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolforge_i18n-0.0.9.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

toolforge_i18n-0.0.9-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file toolforge_i18n-0.0.9.tar.gz.

File metadata

  • Download URL: toolforge_i18n-0.0.9.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for toolforge_i18n-0.0.9.tar.gz
Algorithm Hash digest
SHA256 c1dc0bf3eca419d54a95d5120acc973546cdd343750bf1fe2b6521b380ae5858
MD5 e7b12e3e74deb2da56ea53b5e47ad4e2
BLAKE2b-256 f797e9d92cc6a90506a48c6019d370271403d26afc788e2fda8fd5302c0dcc63

See more details on using hashes here.

File details

Details for the file toolforge_i18n-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for toolforge_i18n-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ea7901b1d1b3d175e8fa42e56a86fbe42d696086abccafb8d14b5568f0b1e59b
MD5 f30bed4f23c89c19a25f28c9766aebaa
BLAKE2b-256 c130f71bf96c1dd501ac2cbdd2974dc2ca423d3fae9b40560843e897de01d311

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page