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.6.tar.gz
(15.6 kB
view details)
Built Distribution
File details
Details for the file local_lang-0.0.6.tar.gz
.
File metadata
- Download URL: local_lang-0.0.6.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f6b74062d8b27f7e07bcaaefbfd2a6d689fdfe8794873f105e9cf75d225b19 |
|
MD5 | 29066b5daefbe4195673b51604d8050e |
|
BLAKE2b-256 | e4ee2915b8e6eaedb247eca817290308f49a8141efa41bb74b7cb597e621f0ca |
File details
Details for the file local_lang-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: local_lang-0.0.6-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a80dcb9d1718db2a6b86c529368f2f8e9fb6a486b1ff0dbf379d8325a2acf6b8 |
|
MD5 | a253600559e6e55c50af1f9ae4a5ea4f |
|
BLAKE2b-256 | 30f86328402b452ae2e0fd4ce0ace41f6c0cb39b2e43caefd99c0d990679358d |