Skip to main content

A small package to localise your python application

Project description

LocalLang

Installation

pip install local-lang

Example

test.py

from src.locallang import LangInit
import datetime

localisation = LangInit()

local = localisation.getLocalisation(lang="en_us")

print(local.hey())
print(local.hello_world())
print(local.toDay(date=datetime.datetime.now()))
print(local.thisTime(time=datetime.datetime.now().time()))
print(local.testStr(strText="Hello world!"))
print(local.testInt(intNum=1))
print(local.testFloat(floatNum=1.5))
print(local.testBool(boolValue=True))
print(local.test(test=1.5))

local = localisation.getLocalisation(lang="fr")

print(local.hey())
print(local.hello_world())
print(local.toDay(date=datetime.datetime.now()))
print(local.thisTime(time=datetime.datetime.now().time()))
print(local.testStr(strText="Bonjour tout le monde !"))
print(local.testInt(intNum=2))
print(local.testFloat(floatNum=2.5))
print(local.testBool(boolValue=False))
print(local.test(test="coucou"))

en_us.json

{
    "hey": "Hey!",
    "hello_world": "Hello world!",
    "toDay": "Date: {date}",
    "@toDay": {
        "placeholders": {
            "date": {
                "type": "datetime",
                "format": "%Y/%m/%d %H:%M"
            }
        }
    },
    "thisTime": "Time: {time}",
    "@thisTime": {
        "placeholders": {
            "time": {
                "type": "time",
                "format": "%H:%M"
            }
        }
    },
    "testStr": "Test: {strText}",
    "@testStr": {
        "placeholders": {
            "strText": {
                "type": "str"
            }
        }
    },
    "testInt": "Test: {intNum}",
    "@testInt": {
        "placeholders": {
            "intNum": {
                "type": "int"
            }
        }
    },
    "testFloat": "Test: {floatNum}",
    "@testFloat": {
        "placeholders": {
            "floatNum": {
                "type": "float"
            }
        }
    },
    "testBool": "Test: {boolValue}",
    "@testBool": {
        "placeholders": {
            "boolValue": {
                "type": "bool"
            }
        }
    },
    "test": "Test: {test}"
}

fr.json

{
    "hey": "Coucou !",
    "hello_world": "Bonjour tout le monde!",
    "toDay": "Date: {date}",
    "thisTime": "Time: {time}",
    "testStr": "Test: {strText}",
    "testInt": "Test: {intNum}",
    "testFloat": "Test: {floatNum}",
    "testBool": "Test: {boolValue}",
    "test": "Test: {test}"
}

result in consol

Hey!
Hello world!
Date: 2023/05/07 00:15
Time: 00:15
Test: Hello world!
Test: 1
Test: 1.5
Test: True
Test: 1.5
Coucou !
Bonjour tout le monde!
Date: 2023/05/07 00:15
Time: 00:15
Test: Bonjour tout le monde !
Test: 2
Test: 2.5
Test: False
Test: coucou

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

local_lang-0.0.9.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

local_lang-0.0.9-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: local_lang-0.0.9.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for local_lang-0.0.9.tar.gz
Algorithm Hash digest
SHA256 0368b934d4543058a0f17b439045cef30031cfe5fb14fb1782436e0f7db0f0a6
MD5 91d74c39f2dfb014ef7576c6a3b53f5c
BLAKE2b-256 d40bfff42c164c415db503bf3e1e6843c683bae157010851ba904d87332136ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: local_lang-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for local_lang-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b6cad764cfd19f4f7a5ab0dcafe65e2bb3715868b8125e12c2792f5755285b45
MD5 11d99913292b7ca0401958b52cacac6e
BLAKE2b-256 5c9e93fcdcc37766a0856aa5737d6bd2916a7fcb9d7313c9d5d7708ef7eaa42e

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