Skip to main content

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

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.1.1.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

toolforge_i18n-0.1.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for toolforge_i18n-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f7546c1f6d817a4de690ab02608785492686ef2eea07e4f0a04bcfc308ad0ad6
MD5 b2fd3f4499990d39ff42622c14dd9a01
BLAKE2b-256 a9f21ab0f040a837f1f8998178bf9640278f4c94d0056d5c4bae8e899c40740f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toolforge_i18n-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cf5b32354f8c369948e360a8742e3d92f9e37f02dbd778226df977e11e19a0f
MD5 7a86ca6d8cd51537cd819523881af61a
BLAKE2b-256 309b4e1e34a04c932dd89df0f5e3ceedb487f1a76b87c36dcd3138f6bbf004cc

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