for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
#!/usr/bin/env python3
import os
import ast
class Localization():
"""多言語化のクラス.
・多言語化にあるプログラム群
Args:
locale_var (str): ロケーション
NEDITOR (str): neditor.txtの値
"""
def __init__(self, locale_var, NEDITOR):
path_to_locale_dir = os.path.abspath(
os.path.join(
os.getcwd(),
"./locale/{0}/".format(locale_var[0])
)
if os.path.exists(path_to_locale_dir) is False:
os.makedirs(path_to_locale_dir)
with open(
"{0}/neditor.txt".format(path_to_locale_dir),
encoding='utf-8',
mode='w'
) as f:
f.write(NEDITOR)
encoding='utf-8'
l_strip = f.read()
self.dic = ast.literal_eval(l_strip)
def get_dict(self, list):
"""翻訳結果の取得の処理.
・翻訳結果を取得し返す。なければデフォルト値を返す。
list (str): デフォルト値
Returns:
str: 翻訳結果
if self.dic[list]:
dic = self.dic[list]
else:
dic = list
return dic