Implemented Transifex
This commit is contained in:
parent
88a061a0ff
commit
3628348322
|
@ -0,0 +1,5 @@
|
||||||
|
FROM python:3
|
||||||
|
ADD requirements.txt /
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
ADD transifex_demo.py /
|
||||||
|
CMD [ "python", "./transifex_demo.py" ]
|
|
@ -0,0 +1,10 @@
|
||||||
|
# docker-compose.yml
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
|
||||||
|
service-name:
|
||||||
|
image: transifex-docker
|
||||||
|
# environment:
|
||||||
|
# - GREETING=hello
|
||||||
|
env_file:
|
||||||
|
- ./transifex.env
|
|
@ -0,0 +1,16 @@
|
||||||
|
asttokens==2.2.1
|
||||||
|
certifi==2022.12.7
|
||||||
|
charset-normalizer==2.1.1
|
||||||
|
click==8.1.3
|
||||||
|
future==0.18.2
|
||||||
|
idna==3.4
|
||||||
|
parsimonious==0.10.0
|
||||||
|
pyseeyou==1.0.2
|
||||||
|
python-dotenv==0.21.0
|
||||||
|
pytz==2022.6
|
||||||
|
regex==2022.10.31
|
||||||
|
requests==2.28.1
|
||||||
|
six==1.16.0
|
||||||
|
toolz==0.12.0
|
||||||
|
transifex-python==3.0.3
|
||||||
|
urllib3==1.26.13
|
|
@ -1,14 +1,17 @@
|
||||||
from transifex.native.daemon import daemon
|
"""Transifex basic implementation using python native sdk """
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
from transifex.native import init, tx
|
from transifex.native import init, tx
|
||||||
from transifex.native.rendering import PseudoTranslationPolicy, SourceStringErrorPolicy
|
|
||||||
from transifex.native.parsing import SourceString
|
from transifex.native.parsing import SourceString
|
||||||
|
|
||||||
init(token='1/6e212800e39991406f0001245517708823f293b8', languages=['el', 'fr', 'en'], secret='1/47cc0fcea6d5f229a618ae0a20e2b60113738fe1')
|
env_path=os.path.join(os.getcwd(),'transifex.env')
|
||||||
|
load_dotenv(env_path)
|
||||||
|
token = os.getenv('token')
|
||||||
|
secret = os.getenv('secret')
|
||||||
|
init(token=token, languages=['el', 'fr', 'en'], secret=secret)
|
||||||
# Add some strings to push
|
# Add some strings to push
|
||||||
strings = [SourceString('My Addresses')]
|
strings = [SourceString('My Addresses')]
|
||||||
|
|
||||||
response_content = tx.push_source_strings(strings)
|
response_content = tx.push_source_strings(strings)
|
||||||
print(response_content)
|
|
||||||
tx.fetch_translations()
|
tx.fetch_translations()
|
||||||
el_translation = tx.translate('My Addresses', 'fr')
|
el_translation = tx.translate('My Addresses', 'fr')
|
||||||
print(el_translation)
|
print(el_translation)
|
||||||
|
|
Reference in New Issue