A small package to localise your python application
Project description
LocalLang
Installation
pip install local-lang
Example
test.py
from 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
Release history Release notifications | RSS feed
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.12.tar.gz
(18.6 kB
view details)
Built Distribution
File details
Details for the file local_lang-0.0.12.tar.gz
.
File metadata
- Download URL: local_lang-0.0.12.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 173e0931a9221cf84fa2e53234b042c7695d7f6f236849a676e0e58d0ee20652 |
|
MD5 | 1a0d8c7e9acefe8920298ab336d26e19 |
|
BLAKE2b-256 | dbd2fadbdc7687e463508cfa6748d99d6937a0dda3a7287b225a6312aefca5bd |
File details
Details for the file local_lang-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: local_lang-0.0.12-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c38f4c893cea8671a24c32232d7ebd8e2fb1aaf34b4fd019389e161117d255 |
|
MD5 | b51c9b110594561e69bf0381e4fbe3c4 |
|
BLAKE2b-256 | 2f44c35f4da634ab7f4a4b392f449c9d303d803bb268d0ab4abd10fc97ad7aa1 |