Skip to main content

i18n for Kivy

Project description

kivy_garden.i18n

Internationalization support for Kivy applications.

from kivy_garden.i18n.localizer import MappingBasedTranslatorFactory, Localizer

translations = {
    "greeting": {
        "ja": "おはよう",
        "en": "morning",
    },
    "app title": {
        "ja": "初めてのKivyプログラム",
        "en": "My First Kivy App",
    },
}
localizer = Localizer(MappingBasedTranslatorFactory(translations))

l = localizer
l.lang = "en"  # Set the "current language" to "en"
assert l.font_name == "Roboto"
assert l._("greeting") == "morning"
assert l._("app title") == "My First Kivy App"

l.lang = "ja"
assert l.font_name == "<a pre-installed Japanese font>"
assert l._("greeting") == "おはよう"
assert l._("app title") == "初めてのKivyプログラム"

Bindings:

from kivy.lang import Builder

localizer.install(name="l")
label = Builder.load_string("""
Label:
    font_name: l.font_name
    text: l._("greeting")
""")
localizer.lang = "en"
assert label.font_name == "Roboto"
assert label.text == "morning"
localizer.lang = "ja"
assert label.font_name == "<a pre-installed Japanese font>"
assert label.text == "おはよう"

Installation

Pin the minor version.

pip install "kivy-garden-i18n>=0.3,<0.4"

Tested on

  • CPython 3.10 + Kivy 2.3
  • CPython 3.11 + Kivy 2.3
  • CPython 3.12 + Kivy 2.3
  • CPython 3.13 + Kivy 2.3

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

kivy_garden_i18n-0.3.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kivy_garden_i18n-0.3.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file kivy_garden_i18n-0.3.0.tar.gz.

File metadata

  • Download URL: kivy_garden_i18n-0.3.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kivy_garden_i18n-0.3.0.tar.gz
Algorithm Hash digest
SHA256 86b50a19ef4a70aa5eb157d616b8d8e80bd31596f396cdc20ed58f5d525bef4d
MD5 9d9b42391f8eab7f7917adac746a026b
BLAKE2b-256 b3637ad6279062d6dd97ed0a58504da2e093a9164d87cec78d78fa6e31818fac

See more details on using hashes here.

Provenance

The following attestation bundles were made for kivy_garden_i18n-0.3.0.tar.gz:

Publisher: release.yml on gottadiveintopython/i18n

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kivy_garden_i18n-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kivy_garden_i18n-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8ec351c40e32d82915453413ea90e8ee248837c53b74ca24417b22cf9b6039b
MD5 64f3462120cd991972293b9b1bf835ff
BLAKE2b-256 d46a1b0b0eb1114e60c79d7aa1767c5e3877c94036667f5ee95253657e08adad

See more details on using hashes here.

Provenance

The following attestation bundles were made for kivy_garden_i18n-0.3.0-py3-none-any.whl:

Publisher: release.yml on gottadiveintopython/i18n

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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