Django module for multi languages management
Project description
django-text-manager - no more problems with texts for bots, websites, etc.
v0.1.1 - Basic functionality with api
Documentation
settings.py
INSTALLED_APPS = [
...
"textmanager",
...
]
TEXT_MANAGER_EXTRA_LANGUAGES = ['uk'] # Optional, default languages when u add new text
TEXT_MANAGER_AVAILABLE_LANGUAGES = ['ru', 'uk', 'en'] # Optional, list of availbale languages in project
How to add languages? (load in database 107 different languages)
python3 manage.py migrate
python3 manage.py loadlanguages
Usage
from textmanager.models import Text
text = Text.objects.get(unique_id='test').render(language="en", params={
"var1": "friend"
})
print(text)
# >>> Hello, friend! - text in db: Hello, {{ var1 }}!
API
urls.py
from django.urls import path, include
urlpatterns = [
path("textmanager/", include("textmanager.urls")),
]
how to send request?
import requests
import json
resp = requests.post(url="http://0.0.0.0:1234/textmanager/text/", json={
"unique_id": "test",
"language": "en", # optional, default=None
"render_with_jinja": False, # optional, default=true
"params": {} # optional, default={}
}, headers={"Authorization": "Token ****"})
data = json.loads(resp.text)
print(data)
# >>> {'text': 'Hello, {{ var1 }}!'} # if language specified
# >>> {
# 'texts': [
# {
# 'language': {
# 'alpha2': 'en',
# 'alpha3_b': 'eng',
# 'english_name': 'English',
# 'language_name': 'English',
# 'flag': '🇬🇧'
# },
# 'text': 'Hello, {{ var1 }}!'
# }, ...
# ]
# }# if language is not specified
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
django-text-manager-0.1.2.tar.gz
(14.5 kB
view hashes)
Close
Hashes for django-text-manager-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43a10c4ca8eb83b7a23113dbfe3553d6ff1f30f00969795ac584ee26215d05ee |
|
MD5 | 895e750983c61aecbdd3f70c288ec35f |
|
BLAKE2b-256 | 985ad03f1197abb45fc598ca508f392436910cabbce5451abeb62bb0a430befd |