All Projects → delivrance → plate

delivrance / plate

Licence: MIT License
Internationalization library for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to plate

Frenchkiss.js
The blazing fast lightweight internationalization (i18n) module for javascript
Stars: ✭ 776 (+2403.23%)
Mutual labels:  i18n, translation, internationalization, localization
i18n
internationalize projects to Arabic
Stars: ✭ 67 (+116.13%)
Mutual labels:  i18n, translation, internationalization, localization
React Intl Hooks
React hooks for internationalization without the hassle ⚛️🌍
Stars: ✭ 64 (+106.45%)
Mutual labels:  i18n, translation, internationalization, localization
inlang
Open Source Localization Solution for Software.
Stars: ✭ 160 (+416.13%)
Mutual labels:  i18n, translation, internationalization, localization
Node Gettext
A JavaScript implementation of gettext, a localization framework.
Stars: ✭ 175 (+464.52%)
Mutual labels:  i18n, translation, internationalization, localization
Easy localization
Easy and Fast internationalizing your Flutter Apps
Stars: ✭ 407 (+1212.9%)
Mutual labels:  i18n, translation, internationalization, localization
Phabricator zh hans
Phabricator zh-Hans Translation & Tools.
Stars: ✭ 113 (+264.52%)
Mutual labels:  i18n, translation, internationalization, localization
Eo Locale
🌏Internationalize js apps 👔Elegant lightweight library based on Internationalization API
Stars: ✭ 290 (+835.48%)
Mutual labels:  i18n, translation, internationalization, localization
fluent-vue
Internationalization plugin for Vue.js
Stars: ✭ 137 (+341.94%)
Mutual labels:  i18n, translation, internationalization, localization
Formatjs
The monorepo home to all of the FormatJS related libraries, most notably react-intl.
Stars: ✭ 12,869 (+41412.9%)
Mutual labels:  i18n, translation, internationalization, localization
rosetta
A blazing fast internationalization (i18n) library for Crystal with compile-time key lookup.
Stars: ✭ 23 (-25.81%)
Mutual labels:  i18n, translation, internationalization, localization
Weblate
Web based localization tool with tight version control integration.
Stars: ✭ 2,719 (+8670.97%)
Mutual labels:  i18n, translation, internationalization, localization
React Localize Redux
Dead simple localization for your React components
Stars: ✭ 384 (+1138.71%)
Mutual labels:  i18n, translation, internationalization, localization
Fluent.js
JavaScript implementation of Project Fluent
Stars: ✭ 622 (+1906.45%)
Mutual labels:  i18n, translation, internationalization, localization
Js Lingui
🌍📖 A readable, automated, and optimized (5 kb) internationalization for JavaScript
Stars: ✭ 3,249 (+10380.65%)
Mutual labels:  i18n, translation, internationalization, localization
Pseudo Localization
Dynamic pseudo-localization in the browser and nodejs
Stars: ✭ 109 (+251.61%)
Mutual labels:  i18n, translation, internationalization, localization
Traduora
Ever® Traduora - Open-Source Translation Management Platform
Stars: ✭ 1,580 (+4996.77%)
Mutual labels:  i18n, translation, internationalization, localization
Mojito
An automation platform that enables continuous localization.
Stars: ✭ 256 (+725.81%)
Mutual labels:  i18n, translation, internationalization, localization
Dom I18n
Provides a very basic HTML multilingual support using JavaScript
Stars: ✭ 125 (+303.23%)
Mutual labels:  i18n, translation, internationalization, localization
React Translated
A dead simple way to add complex translations (i18n) in a React (DOM/Native) project 🌎🌍🌏
Stars: ✭ 176 (+467.74%)
Mutual labels:  i18n, translation, internationalization, localization

Plate

Internationalization Library for Python

Plate (Python translate) is an i18n library for Python that gives your application the ability to speak many languages. It is designed to be simple and straightforward to use for developers and easy for translators.

Features

  • Translations based on JSON files
  • Interpolated translations
  • Pluralization
  • Emoji

Installing

$ pip3 install plate

Setup

Plate is not going to perform any translation; what it does, instead, is simply providing a way to manage already-translated phrases so that they can be easily accessed from your application code.

These translated phrases are kept in JSON files stored in a folder inside the application working directory and organized by their respective language codes. The JSON keys are in common to all translations and the values of each contain the translated phrases.

  1. Create a new locales folder in your working directory to store translation files.
  2. Put files named after their language codes: en_US.json, it_IT.json, and so on. All available language codes can be found here.
  3. Start adding new phrases and translations. Here's an example for en_US.json and it_IT.json
    {
        "hello": "Hello", 
        "morning": "Good morning, {name}",
        "drink": "Let's drink :SAKE: together",
        "apples": "No apples | One apple | {count} apples"
    }
    {
        "hello": "Ciao", 
        "morning": "Buongiorno, {name}",
        "drink": "Beviamo :SAKE: insieme",
        "apples": "Nessuna mela | Una mela | {count} mele"
    }

Usage

Instantiation

First of all, create a new Plate instance. Plate will automatically look for files inside the locales folder or another custom folder you pass to the root parameter. The default and the fallback locale is en_US, by default.

from plate import Plate

plate = Plate()

Translation

Translate a phrase by simply passing a key and a language code of the destination locale.

plate("hello", "it_IT")  # Ciao

You can also set a new default locale to have all subsequent translations in that language.

plate.set_locale("it_IT")
plate("hello")  # Ciao

Or, get a translator for a given locale instead, so that the default locale will be kept unchanged.

italian = plate.get_translator("it_IT")
italian("hello")  # Ciao

Note: The examples below will assume plate.set_locale("it_IT") for conciseness.

Interpolation

Pass named arguments to interpolate your translations.

plate("morning", name="Dan")  # Buongiorno, Dan

Emoji

Emoji can be added with :EMOJI_NAME: inside your sources and are automatically inserted with the actual values. All available emoji can be found here. You can search for, visualize them and grab their names at https://emojipedia.org/.

plate("drink")  # Beviamo 🍶 insieme

Pluralization

Pluralization is done by keeping all the plural cases separated by a pipe | (by default, customizable) and by using the special interpolation key {count}. The following example shows how to translate and pluralize a phrase for count cases of zero, one and more.

plate("apples", count=0)  # Nessuna mela
plate("apples", count=1)  # Una mela
plate("apples", count=7)  # 7 mele

License

MIT © 2020 Dan

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].