|
|
@@ -2,7 +2,7 @@
|
|
|
Author: deng.yinping deng.yinping@muchinfo.cn
|
|
|
Date: 2024-12-06 10:22:52
|
|
|
LastEditors: deng.yinping deng.yinping@muchinfo.cn
|
|
|
-LastEditTime: 2025-03-06 15:57:53
|
|
|
+LastEditTime: 2025-03-07 16:16:35
|
|
|
FilePath: \MTP20_WEB_GLOBAL_i18n_Tool\common.py
|
|
|
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
'''
|
|
|
@@ -57,14 +57,15 @@ class CommonUti:
|
|
|
return leaf_paths_dict
|
|
|
|
|
|
@staticmethod
|
|
|
- def generate_excle_by_oem(oem, output_folder, zh_data, en_data, th_data, tw_data):
|
|
|
+ def generate_excle_by_oem(oem, output_folder, zh_data, en_data, th_data, tw_data, vi_data):
|
|
|
df = pd.DataFrame.from_dict(zh_data, orient='index', columns=['zh-CN'])
|
|
|
|
|
|
# 将 其它 的值合并到 DataFrame 中
|
|
|
df['en-US'] = df.index.map(en_data).fillna('')
|
|
|
df['th-TH'] = df.index.map(th_data).fillna('')
|
|
|
df['zh-TW'] = df.index.map(tw_data).fillna('')
|
|
|
-
|
|
|
+ df['vi-VN'] = df.index.map(vi_data).fillna('')
|
|
|
+
|
|
|
# 重置索引,以便将索引变为一列
|
|
|
df.reset_index(inplace=True)
|
|
|
df.rename(columns={'index': 'Key'}, inplace=True) # 将索引列重命名为 'Key'
|
|
|
@@ -78,11 +79,12 @@ class CommonUti:
|
|
|
ws = wb.active
|
|
|
|
|
|
# 指定列宽
|
|
|
- ws.column_dimensions['A'].width = 60 # 设置第一列宽度
|
|
|
- ws.column_dimensions['B'].width = 50 # 设置第二列宽度
|
|
|
- ws.column_dimensions['C'].width = 50 # 设置第三列宽度
|
|
|
- ws.column_dimensions['D'].width = 50 # 设置第四列宽度
|
|
|
- ws.column_dimensions['E'].width = 50 # 设置第五列宽度
|
|
|
+ ws.column_dimensions['A'].width = 40 # 设置第一列宽度 KEY
|
|
|
+ ws.column_dimensions['B'].width = 40 # 设置第二列宽度 中文
|
|
|
+ ws.column_dimensions['C'].width = 40 # 设置第三列宽度 英文
|
|
|
+ ws.column_dimensions['D'].width = 40 # 设置第四列宽度 泰文
|
|
|
+ ws.column_dimensions['E'].width = 40 # 设置第五列宽度 繁体
|
|
|
+ ws.column_dimensions['F'].width = 40 # 设置第六列宽度 越南语
|
|
|
|
|
|
# 保存更改
|
|
|
wb.save(output_file)
|
|
|
@@ -92,7 +94,7 @@ class CommonUti:
|
|
|
@staticmethod
|
|
|
def update_excel_by_inc(oem, output_folder, inc_name):
|
|
|
''' 增量更新,在生成excel里标注新增的key为黄色 '''
|
|
|
- # 读取输出的Excel文件, 格式:key(A) zh-CN(B) en-US(C) th-TH(C) zh-TW(D)
|
|
|
+ # 读取输出的Excel文件, 格式:key(A) zh-CN(B) en-US(C) th-TH(D) zh-TW(E) vi-VN(F)
|
|
|
inc_file = output_folder + "/excels/" + inc_name + ".xlsx"
|
|
|
if not os.path.exists(inc_file):
|
|
|
return
|
|
|
@@ -132,9 +134,11 @@ class CommonUti:
|
|
|
oem, json_folder, oem_json_folder, 'th-TH')
|
|
|
tw_data = CommonUti.read_data_from_json(
|
|
|
oem, json_folder, oem_json_folder, 'zh-TW')
|
|
|
+ vi_data = CommonUti.read_data_from_json(
|
|
|
+ oem, json_folder, oem_json_folder, 'vi-VN')
|
|
|
|
|
|
CommonUti.generate_excle_by_oem(
|
|
|
- oem, output_folder, zh_data, en_data, th_data, tw_data)
|
|
|
+ oem, output_folder, zh_data, en_data, th_data, tw_data, vi_data)
|
|
|
|
|
|
@staticmethod
|
|
|
def read_data_from_json(oem, json_folder, oem_json_folder, lang):
|
|
|
@@ -170,8 +174,11 @@ class CommonUti:
|
|
|
|
|
|
# 将 A 列和 E 列转换为zh-TW字典
|
|
|
dict_tw = dict(zip(df.iloc[:, 0], df.iloc[:, 4]))
|
|
|
+
|
|
|
+ # 将 A 列和 F 列转换为vi-VN字典
|
|
|
+ dict_vi = dict(zip(df.iloc[:, 0], df.iloc[:, 5]))
|
|
|
|
|
|
- return dict_cn, dict_en, dict_th, dict_tw
|
|
|
+ return dict_cn, dict_en, dict_th, dict_tw, dict_vi
|
|
|
|
|
|
@staticmethod
|
|
|
def modify_json_values(data, modify_func, path="", extra_data=None, exclude_data=None):
|