Skip to main content

i18npy

PyPI PyPI - Python Version Codecov GitHub

This is Python implementation of roddeh/i18njs (http://i18njs.com/). It's fully compatible with it's JSON dictionaries syntax.

Usage

Installation

pip install i18npy

Samples

With external dictionary and global i18n instance

pl.json

{
  "values": {
    "Hello World": "Witaj świecie",
    "I have %n cookies": [
      [null, null, "Nie ma rączek, nie ma ciasteczek"],
      [0, 0, "Nie mam ciasteczek"],
      [1, 1, "Mam jedno ciasteczko"],
      [2, 4, "Mam %n ciasteczka"],
      [5, null, "Mam %n ciasteczek"]
    ]
  }
}

code

from i18npy import i18n, i18n_load

i18n_load("./pl.json")

i18n("Hello World")
# Witaj świecie

KEY = "I have %n cookies"
i18n(KEY, None)
# Nie ma rączek, nie ma ciasteczek

i18n(KEY, 0)
# Nie mam ciasteczek

i18n(KEY, 1)
# Mam jedno ciasteczko

i18n(KEY, 3)
# Mam 3 ciasteczka

i18n(KEY, 5)
# Mam 5 ciasteczek

Create translator instances

import i18npy

lang_pl = i18npy.create({
  "values": {
    "Hello World": "Witaj świecie",
    "I have %n cookies": [
      [None, None, "Nie ma rączek, nie ma ciasteczek"],
      [0, 0, "Nie mam ciasteczek"],
      [1, 1, "Mam jedno ciasteczko"],
      [2, 4, "Mam %n ciasteczka"],
      [5, None, "Mam %n ciasteczek"]
    ]
  }
})

lang_pl.translate("Hello World")
# Witaj świecie

lang_pl.translate("I have %n cookies", 3)
# Mam 3 ciasteczka

Word of appreciation

The original i18njs library ha been written by roddeh. The library code is based on his code, which is also licensed by MIT.

License

This project is licensed under MIT License - see the LICENSE file for details.

Metadata

Release files for i18npy 1.0.0

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

Source distribution (sdist)

Source distribution for i18npy 1.0.0
File Size Uploaded Provenance Actions
i18npy-1.0.0.tar.gz 5.6 kB Without provenance Details for i18npy-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for i18npy 1.0.0
File Interpreter ABI Platform Actions
i18npy-1.0.0-py3-none-any.whl Python 3 none any Details for i18npy-1.0.0-py3-none-any.whl

Total release size: 11.6 kB

Release files / i18npy-1.0.0.tar.gz

Download URL i18npy-1.0.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1eba2f37659d313358c667c227ff6f65f817070f84e5aec9d104919bffc57a44
BLAKE2b-256 checksum
How to use checksums
5bb7b43af49c0db58f80932b880598df32035f158048f3b720bc1f17509a3c65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-7642-generic

Release files / i18npy-1.0.0-py3-none-any.whl

Download URL i18npy-1.0.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ca84f4396a4f747a104e98ce315e2f1d1d1ab554563405c584b220ba7ae6117
BLAKE2b-256 checksum
How to use checksums
319891ff6a331f97e459bd6a7e0c028d15002ac5bd44e376b3a78a3516fe956a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.8.10 Linux/5.4.0-7642-generic

Security for i18npy 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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