diff --git a/.github/scripts/translate_localization.py b/.github/scripts/translate_localization.py
index a88701f9..22743089 100644
--- a/.github/scripts/translate_localization.py
+++ b/.github/scripts/translate_localization.py
@@ -23,11 +23,11 @@
def translate_text(text, target_language):
try:
response = client.chat.completions.create(
- model="gpt-4o-mini",
+ model="gpt-4o-mini",
messages=[
- {"role": "system", "content": "You are a helpful assistant."},
- {"role": "user", "content": f"Translate the following Japanese text to {target_language}. Return only the translated text without any additional explanations or notes.\n\n{text}"}
- ]
+ {"role": "system", "content": "You are a helpful assistant."},
+ {"role": "user", "content": f"Translate the following Japanese text to {target_language}. Return only the translated text without any additional explanations or notes.\n\n{text}"}
+ ]
)
# 翻訳結果を取得
translation = response.choices[0].message.content.strip()
@@ -36,11 +36,11 @@ def translate_text(text, target_language):
print(f"翻訳中にエラーが発生しました:{e}")
return None
-# 各行に対して翻訳を実行
-for idx, row in df.iterrows():
+# 各行に対して翻訳を実行(先頭行をスキップ)
+for idx, row in df.iloc[1:].iterrows():
japanese_text = row.get('Japanese(ja)', '')
key = row.get('Key', '')
-
+
# 日本語テキストが存在する場合のみ翻訳を実行
if pd.notnull(japanese_text) and japanese_text.strip() != '':
print(f"キー '{key}' の翻訳を実行します。")
@@ -88,7 +88,6 @@ def write_custom_csv(df, csv_path):
data_row.append(f'"{value}"')
csvfile.write(','.join(data_row) + '\n')
-
# カスタム関数でCSVを保存
write_custom_csv(df, csv_path)
print("翻訳が完了し、CSVファイルが更新されました。")
\ No newline at end of file
diff --git a/Assets/uDesktopMascot/Editor/LocalizationTableSaveProcessor.cs b/Assets/uDesktopMascot/Editor/LocalizationTableSaveProcessor.cs
new file mode 100644
index 00000000..89366766
--- /dev/null
+++ b/Assets/uDesktopMascot/Editor/LocalizationTableSaveProcessor.cs
@@ -0,0 +1,178 @@
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Localization.Tables;
+using UnityEditor.Localization;
+using System.IO;
+using System.Text;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace uDesktopMascot.Editor
+{
+ ///
+ /// ローカリゼーションテーブルをセーブ時に自動でCSVにエクスポートする処理
+ ///
+ public class LocalizationTableSaveProcessor : AssetModificationProcessor
+ {
+ ///
+ /// アセットが保存される直前に呼び出されるコールバック。
+ /// 保存されるアセットがローカリゼーションテーブルである場合、CSVエクスポートを行います。
+ ///
+ /// 保存されるアセットのパスの配列
+ /// 保存されるアセットのパスの配列
+ private static string[] OnWillSaveAssets(string[] paths)
+ {
+ // 保存されるアセットパスをループ
+ foreach (var path in paths)
+ {
+ // アセットがローカリゼーションテーブルかどうかを確認
+ var asset = AssetDatabase.LoadAssetAtPath