2022-12-14 07:35:57 +00:00
|
|
|
"""Transifex basic implementation using python native sdk """
|
|
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
2022-12-14 07:33:48 +00:00
|
|
|
from transifex.native import init, tx
|
|
|
|
from transifex.native.parsing import SourceString
|
|
|
|
|
2022-12-14 07:35:57 +00:00
|
|
|
env_path=os.path.join('transifex.env')
|
|
|
|
if os.path.exists(env_path):
|
|
|
|
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
|
|
|
|
strings = [SourceString('My Addresses')]
|
|
|
|
response_content = tx.push_source_strings(strings)
|
|
|
|
tx.fetch_translations()
|
|
|
|
el_translation = tx.translate('My Addresses', 'fr')
|
|
|
|
print(el_translation)
|
2022-12-14 07:33:48 +00:00
|
|
|
|
2022-12-14 07:35:57 +00:00
|
|
|
else:
|
|
|
|
raise NotADirectoryError("transifex.env")
|