Complete Guide to Using the Script This script provides a graphical user interface (GUI) for managing JSON files related to Stardew Valley mod translations. It features seven primary functions, each represented by a button in the interface.
Complete Guide to Using the Script
Spoiler:
Show
Button Functions
Extract Key-Original Pairs:
Purpose: Extracts the original English text from the base mod's JSON files (CP.json, i18n.json, STF.json, mail.json, JA.json) and creates new files with the "_key_original.json" suffix. These new files contain a dictionary where the keys are the original English text strings and the values are the corresponding in-game keys.
Input: The script looks for the base JSON files in the same directory where it's located.
Output: Files named like "CP_key_original.json", "i18n_key_original.json", etc.
Extract Original Text:
Purpose: Extracts only the original English text from the "_key_original.json" files created in the previous step. This creates files with the "_NeedTranslate.json" suffix, which contain lists of the original English text strings, ready for translation.
Input: The script looks for files like "CP_key_original.json", "i18n_key_original.json", etc.
Output: Files named like "CP_NeedTranslate.json", "i18n_NeedTranslate.json", etc.
Merge Translated Text
Purpose: Combines translated text from files named like "CP_key_YourTranslated.json" with the original English keys and structure from the corresponding "_key_original.json" files. This creates complete translated JSON files ready for use in the mod.
Input: The script looks for pairs of files like "CP_key_original.json" and "CP_key_YourTranslated.json".
Output: Files named like "CP_YourTranslated.json", containing the full translated content.
Prepare for Transtar
Purpose: Takes the translated text from the "_key_YourTranslated.json" files and inserts it into the original mod's JSON structure. This prepares the files for use with the Transtar translation tool.
Input: The script looks for pairs of files like "CP.json" and "CP_key_YourTranslated.json".
Output: Files named like "CP_ForTranstar_YourTranslated.json", ready for use with Transtar.
Combine Source Files:
Purpose: Combines the original English text from specific JSON files (CP.json, STF.json, mail.json, JA.json) into two output files:
"CP_i18n.json", "STF_i18n.json", etc.: These files contain the original data from each input file, but with the "translation" field replaced with an i18n code, e.g., "{{i18n:CP_key_1}}".
"default.json": This file contains a dictionary where the keys are the i18n codes (e.g., "CP_key_1") and the values are the corresponding original English text strings.
Input: The script looks for files like "CP.json", "STF.json", etc.
Output: Files named "CP_i18n.json", "STF_i18n.json", etc., and a "default.json" file.
Combine Translated Files:
Purpose: Similar to "Combine Source Files", but it uses the translated files generated by "Transfer to Transtar" (like "CP_ForTranstar_YourTranslated.json"). It outputs files with the "_YourTranslated" suffix.
Input: The script looks for files like "CP_ForTranstar_YourTranslated.json", "STF_ForTranstar_YourTranslated.json", etc.
Output: Files named "CP_i18n_YourTranslated.json", "STF_i18n_YourTranslated.json", etc., and a "default_YourTranslated.json" file.
Replace i18n Codes (Original)
Purpose: Takes the i18n codes from the "_i18n.json" files (generated by "Combine Source Files") and replaces them with the corresponding English text from the "default.json" file.
Input: The script looks for pairs of files like "CP_i18n.json" and "default.json".
Output: Files named like "CP_i18n_Return.json", with the i18n codes replaced with the original English text.
Replace i18n Codes (YourTranslated)
Purpose: Similar to "Replace i18n Codes", but it uses the "_i18n_YourTranslated.json" files (generated by "Combine Translated Files") and the "default_YourTranslated.json" file.
Input: The script looks for pairs of files like "CP_i18n_YourTranslated.json" and "default_YourTranslated.json".
Output: Files named like "CP_i18n_YourTranslated_Return.json", with the i18n codes replaced with the translated text.
Three File Processing Section
Labels: Three labels indicate which files to select:
NEW MOD I18N FILE: The i18n file from the new mod version.
OLD MOD I18N FILE: The i18n file from the old mod version.
OLD YourLang I18N FILE: The translated i18n file for your language from the old mod version.
Entry Fields: Three entry fields allow you to see the selected file paths.
Browse Buttons: Three "Browse" buttons allow you to select the corresponding files using a file dialog that opens in the script's directory.
Process Three Files Button: Once you've selected all three files, click this button to process them. The script will compare the three files, transfer matching translations from the old translated file to the new mod's i18n file, and save the result to a new file that you specify.
Notes
The script assumes that all relevant JSON files are located in the same directory as the script itself.
Make sure to follow the correct order of operations for translating your mod. Generally, you would use buttons 1-4 to prepare files for translation, translate the English text in the "_NeedTranslate.json" files, then use buttons 5-8 to generate the final translated mod files.
This guide provides a basic overview. You may need to adapt the process or file names slightly depending on the specific requirements of your mod.
Полное руководство по использованию скрипта
Spoiler:
Show
Описание скрипта
Этот скрипт предоставляет графический интерфейс (GUI) для управления JSON-файлами, связанными с переводами модов Stardew Valley. Он имеет семь основных функций, каждая из которых представлена кнопкой в интерфейсе.
Функции кнопок
Extract Key and Original Text (Извлечь ключ и оригинальный текст):
Цель: Извлекает оригинальный английский текст из базовых JSON-файлов мода (CP.json, i18n.json, STF.json, mail.json, JA.json) и создает новые файлы с суффиксом "_key_original.json". Эти новые файлы содержат словарь, где ключи - это оригинальные английские текстовые строки, а значения - соответствующие ключи в игре.
Вход: Скрипт ищет базовые JSON-файлы в том же каталоге, где он расположен.
Выход: Файлы с именами типа "CP_key_original.json", "i18n_key_original.json" и т.д.
Extract Original Text (Извлечь оригинальный текст):
Цель: Извлекает только оригинальный английский текст из файлов "_key_original.json", созданных на предыдущем шаге. Это создает файлы с суффиксом "_NeedTranslate.json", которые содержат списки оригинальных английских текстовых строк, готовых к переводу.
Вход: Скрипт ищет файлы типа "CP_key_original.json", "i18n_key_original.json" и т.д.
Выход: Файлы с именами типа "CP_NeedTranslate.json", "i18n_NeedTranslate.json" и т.д.
Объединить переводы:
Цель: Объединяет переведенный текст из файлов с именами типа "CP_key_YourTranslated.json" с оригинальными английскими ключами и структурой из соответствующих файлов "_key_original.json". Это создает готовые к использованию в моде полностью переведенные JSON-файлы.
Вход: Скрипт ищет пары файлов типа "CP_key_original.json" и "CP_key_YourTranslated.json".
Выход: Файлы с именами типа "CP_YourTranslated.json", содержащие полный переведенный контент.
Transfer to Transtar (Передать в Transtar):
Цель: Берет переведенный текст из файлов "_key_YourTranslated.json" и вставляет его в оригинальную структуру JSON мода. Это подготавливает файлы для использования с инструментом перевода Transtar.
Вход: Скрипт ищет пары файлов типа "CP.json" и "CP_key_YourTranslated.json".
Выход: Файлы с именами типа "CP_ForTranstar_YourTranslated.json", готовые к использованию с Transtar.
Combine Source Files (Объединить исходные файлы):
Цель: Объединяет оригинальный английский текст из определенных JSON-файлов (CP.json, STF.json, mail.json, JA.json) в два выходных файла:
"CP_i18n.json", "STF_i18n.json" и т.д.: Эти файлы содержат оригинальные данные из каждого входного файла, но поле "translation" заменено на код i18n, например, "{{i18n:CP_key_1}}".
"default.json": Этот файл содержит словарь, где ключи - это коды i18n (например, "CP_key_1"), а значения - соответствующие оригинальные английские текстовые строки.
Вход: Скрипт ищет файлы типа "CP.json", "STF.json" и т.д.
Выход: Файлы с именами "CP_i18n.json", "STF_i18n.json" и т.д., а также файл "default.json".
Цель: Аналогично "Combine Source Files", но использует переведенные файлы, сгенерированные "Transfer to Transtar" (типа "CP_ForTranstar_YourTranslated.json"). Выводит файлы с суффиксом "_YourTranslated".
Вход: Скрипт ищет файлы типа "CP_ForTranstar_YourTranslated.json", "STF_ForTranstar_YourTranslated.json" и т.д.
Выход: Файлы с именами "CP_i18n_YourTranslated.json", "STF_i18n_YourTranslated.json" и т.д., а также файл "default_YourTranslated.json".
Replace i18n Codes (Заменить коды i18n):
Цель: Берет коды i18n из файлов "_i18n.json" (сгенерированных "Combine Source Files") и заменяет их соответствующим английским текстом из файла "default.json".
Вход: Скрипт ищет пары файлов типа "CP_i18n.json" и "default.json".
Выход: Файлы с именами типа "CP_i18n_Return.json", где коды i18n заменены на оригинальный английский текст.
Apply Translations (Применить переводы):
Цель: Аналогично "Replace i18n Codes", но использует файлы "_i18n_YourTranslated.json" (сгенерированные "Combine Translated Files") и файл "default_YourTranslated.json".
Вход: Скрипт ищет пары файлов типа "CP_i18n_YourTranslated.json" и "default_YourTranslated.json".
Выход: Файлы с именами типа "CP_i18n_YourTranslated_Return.json", где коды i18n заменены на переведенный текст.
Раздел обработки трех файлов
Метки: Три метки указывают, какие файлы нужно выбрать:
NEW MOD I18N FILE: Файл i18n из новой версии мода.
OLD MOD I18N FILE: Файл i18n из старой версии мода.
OLD YourLang I18N FILE: Переведенный файл i18n для вашего языка из старой версии мода.
Поля ввода: Три поля ввода позволяют вам видеть выбранные пути к файлам.
Кнопки "Обзор": Три кнопки "Обзор" позволяют вам выбирать соответствующие файлы, используя диалоговое окно выбора файлов, которое открывается в каталоге скрипта.
Кнопка "Обработать три файла": После того, как вы выбрали все три файла, нажмите эту кнопку для их обработки. Скрипт сравнит три файла, перенесет совпадающие переводы из старого переведенного файла в файл i18n нового мода и сохранит результат в новый файл, который вы укажете.
Примечания
Скрипт предполагает, что все соответствующие JSON-файлы находятся в том же каталоге, что и сам скрипт.
Убедитесь, что вы следуете правильному порядку действий для перевода вашего мода. Как правило, вы будете использовать кнопки 1-4 для подготовки файлов к переводу, переводить английский текст в файлах "_NeedTranslate.json", а затем использовать кнопки 5-8 для генерации окончательных переведенных файлов мода.
Это руководство предоставляет базовый обзор. Вам может потребоваться немного адаптировать процесс или имена файлов в зависимости от конкретных требований вашего мода.
1) Add variations 2_only_translation.py for i18n and mail 2) Add variations 3_translation_to_key_and_OLDtranslation for i18n and mail 3) Add Old_translate_to_New.py(This Python script is designed to help you update translations in JSON files based on changes in different versions.)
Updating Mod Translations with Old_translate_to_New.py This guide explains how to use the Old_translate_to_New.py script to efficiently update translations for your mods, leveraging existing translations from older versions or other languages.
What You'll Need:
Transtar: A tool for extracting translation files (CP, i18n, mail) from Stardew Valley mods.
Old_translate_to_New.py: The Python script provided.
Three JSON translation files:
New Target Language (e.g., English): This file contains the most up-to-date English translations for the mod.
Old Target Language (e.g., English): This file contains English translations from an older version of the mod.
Old Source/Reference Language (e.g., Russian, Chinese, Portuguese): This file contains translations in the language you want to use as a reference (e.g., the language you're updating the mod to).
Instructions: 1. Extract Translation Files: Use Transtar to extract the necessary translation files (CP.json, i18n.json, mail.json, etc.) from:
The mod with the new English translations.
An archived version of the mod with the old English translations. (To get the download ID for archived mod versions, use your browser's "View Page Source" feature on the archive page.)
An archived version of the mod with the old translations in your target language.
2. Rename the extracted JSON files to something like: CP_new_en.json (New English) CP_old_en.json (Old English) CP_old_ru.json (Old Russian, or your target language) 3. Run the Script: Execute the Old_translate_to_New.py script. In the GUI window, click the "Выберите Файлы" (Select Files) button. 4. Select and Order Files: Choose the three JSON translation files in the following order: File 1: The JSON file with the NEW target language translations (e.g., CP_new_en.json). File 2: The JSON file with the OLD target language translations (e.g., CP_old_en.json). File 3: The JSON file with the OLD source/reference language translations (e.g., CP_old_ru.json). 5. Choose Output: Select a name and location to save the updated JSON translation file.
I want to add an i18n folder to the CP version mod. How should I use your script? I have already installed Python. Is it correct to directly double-click the ".py" file? I am using this script: “CP_to_I18n.py”. When I double-click it, a black command window appears, then it asks me to select a json file, and I select “content.json”. But the window closes, and I don't see any changes...
1) Install Python 2) Download and run Transtar 3) Drop your mod folder (or just the CP folder) into the Transtar window. 4) Click Extract (if an error pops up, you have an error in the file and it needs to be fixed) (If everything was successful, the programme will give you the NameMod dict folder). 5) Run CP_to_I18n.py and specify the CP.json file in the NameMod dict. 6) Go back to Transtar and click Generate. 7) Get the NameMod translation folder (these are already the mod files converted to i18n) 8) Throw the files from this folder with replacement in the folder of our mod. 9) Profit!!!!!11111
Thanks to your response, I understood how to use it and succeeded! First, understanding how to use "transtar" will make it easier for me to understand your script (it's fantastic!). In your 5 step, after running "CP_to_I18n.py" and selecting CP.json, two JSON files will be saved. The first JSON file still needs to keep the same name: CP.json, in order to use "transtar's" Generate function. The second JSON file should be saved as default.json in the i18n folder. Thanks again!
You're very welcome! I'm glad my explanation was helpful and you were able to get it working. Let me know if you have any other questions or need further assistance.
hello I need help making an i18 for my mod SSS, just for the config, i am new to coding and it is hard for me to understand, i have friends who will translate it after it is in i18, thank you in advanced https://www.nexusmods.com/stardewvalley/mods/23095
https://pixeldrain.com/u/ax92kJsV Check it out. (added 9 i18n keys for item descriptions) I also added a Russian translation for myself. The items themselves remain in English, because if you translate their names, everything will break.
I didn't touch the event files, they contain text and can be found in the path. You can also move them to i18n if you want. But my programme didn't capture them, so I decided not to touch them. OpenFireMine.xnb also contains the text of the events, if necessary use xnbcli to unpack them. OpenFire(SVE)\OpenFire\[CP] OpenFire\assets\Events\ (files 0, 2, 4, 6-1, 6-2, 8) and OpenFireMine.xnb
The English version of this mod is different, it made edits to the content file, it can also be done in i18n, but there will be differences in the lines.
I'm having some trouble with the Amon one. I first downloaded the original Chinese one and put it in the mods folder and then replaced some of those files with this one so I didn't think the installation went wrong. Anyways, It won't show his name in game, just 2 symbols that looks like 💢 and the text doesn't work at all with cutscenes, it just shows some lines. Did I do something wrong? I saw you mentioned something about a small mistake in the files, is that why this happened? Can you maybe tell me how to fix it so I can do it myself? :') Thanks anyways for even making these!
85 comments
This script provides a graphical user interface (GUI) for managing JSON files related to Stardew Valley mod translations. It features seven primary functions, each represented by a button in the interface.
Complete Guide to Using the Script
Button Functions
- Extract Key-Original Pairs:
- Purpose: Extracts the original English text from the base mod's JSON files (CP.json, i18n.json, STF.json, mail.json, JA.json) and creates new files with the "_key_original.json" suffix. These new files contain a dictionary where the keys are the original English text strings and the values are the corresponding in-game keys.
- Input: The script looks for the base JSON files in the same directory where it's located.
- Output: Files named like "CP_key_original.json", "i18n_key_original.json", etc.
- Extract Original Text:
- Purpose: Extracts only the original English text from the "_key_original.json" files created in the previous step. This creates files with the "_NeedTranslate.json" suffix, which contain lists of the original English text strings, ready for translation.
- Input: The script looks for files like "CP_key_original.json", "i18n_key_original.json", etc.
- Output: Files named like "CP_NeedTranslate.json", "i18n_NeedTranslate.json", etc.
- Merge Translated Text
- Purpose: Combines translated text from files named like "CP_key_YourTranslated.json" with the original English keys and structure from the corresponding "_key_original.json" files. This creates complete translated JSON files ready for use in the mod.
- Input: The script looks for pairs of files like "CP_key_original.json" and "CP_key_YourTranslated.json".
- Output: Files named like "CP_YourTranslated.json", containing the full translated content.
- Prepare for Transtar
- Purpose: Takes the translated text from the "_key_YourTranslated.json" files and inserts it into the original mod's JSON structure. This prepares the files for use with the Transtar translation tool.
- Input: The script looks for pairs of files like "CP.json" and "CP_key_YourTranslated.json".
- Output: Files named like "CP_ForTranstar_YourTranslated.json", ready for use with Transtar.
- Combine Source Files:
- Purpose: Combines the original English text from specific JSON files (CP.json, STF.json, mail.json, JA.json) into two output files:
- "CP_i18n.json", "STF_i18n.json", etc.: These files contain the original data from each input file, but with the "translation" field replaced with an i18n code, e.g., "{{i18n:CP_key_1}}".
- "default.json": This file contains a dictionary where the keys are the i18n codes (e.g., "CP_key_1") and the values are the corresponding original English text strings.
- Input: The script looks for files like "CP.json", "STF.json", etc.
- Output: Files named "CP_i18n.json", "STF_i18n.json", etc., and a "default.json" file.
- Combine Translated Files:
- Purpose: Similar to "Combine Source Files", but it uses the translated files generated by "Transfer to Transtar" (like "CP_ForTranstar_YourTranslated.json"). It outputs files with the "_YourTranslated" suffix.
- Input: The script looks for files like "CP_ForTranstar_YourTranslated.json", "STF_ForTranstar_YourTranslated.json", etc.
- Output: Files named "CP_i18n_YourTranslated.json", "STF_i18n_YourTranslated.json", etc., and a "default_YourTranslated.json" file.
- Replace i18n Codes (Original)
- Purpose: Takes the i18n codes from the "_i18n.json" files (generated by "Combine Source Files") and replaces them with the corresponding English text from the "default.json" file.
- Input: The script looks for pairs of files like "CP_i18n.json" and "default.json".
- Output: Files named like "CP_i18n_Return.json", with the i18n codes replaced with the original English text.
- Replace i18n Codes (YourTranslated)
- Purpose: Similar to "Replace i18n Codes", but it uses the "_i18n_YourTranslated.json" files (generated by "Combine Translated Files") and the "default_YourTranslated.json" file.
- Input: The script looks for pairs of files like "CP_i18n_YourTranslated.json" and "default_YourTranslated.json".
- Output: Files named like "CP_i18n_YourTranslated_Return.json", with the i18n codes replaced with the translated text.
Three File Processing Section
- Labels: Three labels indicate which files to select:
- NEW MOD I18N FILE: The i18n file from the new mod version.
- OLD MOD I18N FILE: The i18n file from the old mod version.
- OLD YourLang I18N FILE: The translated i18n file for your language from the old mod version.
- Entry Fields: Three entry fields allow you to see the selected file paths.
- Browse Buttons: Three "Browse" buttons allow you to select the corresponding files using a file dialog that opens in the script's directory.
- Process Three Files Button: Once you've selected all three files, click this button to process them. The script will compare the three files, transfer matching translations from the old translated file to the new mod's i18n file, and save the result to a new file that you specify.
NotesПолное руководство по использованию скрипта
Описание скрипта
Этот скрипт предоставляет графический интерфейс (GUI) для управления JSON-файлами, связанными с переводами модов Stardew Valley. Он имеет семь основных функций, каждая из которых представлена кнопкой в интерфейсе.
Функции кнопок
Раздел обработки трех файлов
Примечания
Throw i18n version files on top with replacement
1) Add variations 2_only_translation.py for i18n and mail
2) Add variations 3_translation_to_key_and_OLDtranslation for i18n and mail
3) Add Old_translate_to_New.py (This Python script is designed to help you update translations in JSON files based on changes in different versions.)
Updating Mod Translations with Old_translate_to_New.py
This guide explains how to use the Old_translate_to_New.py script to efficiently update translations for your mods, leveraging existing translations from older versions or other languages.
What You'll Need:
- New Target Language (e.g., English): This file contains the most up-to-date English translations for the mod.
- Old Target Language (e.g., English): This file contains English translations from an older version of the mod.
- Old Source/Reference Language (e.g., Russian, Chinese, Portuguese): This file contains translations in the language you want to use as a reference (e.g., the language you're updating the mod to).
Instructions:1. Extract Translation Files:
Use Transtar to extract the necessary translation files (CP.json, i18n.json, mail.json, etc.) from:
- The mod with the new English translations.
- An archived version of the mod with the old English translations.
- An archived version of the mod with the old translations in your target language.
2. Rename the extracted JSON files to something like:(To get the download ID for archived mod versions, use your browser's "View Page Source" feature on the archive page.)
CP_new_en.json (New English)
CP_old_en.json (Old English)
CP_old_ru.json (Old Russian, or your target language)
3. Run the Script:
Execute the Old_translate_to_New.py script.
In the GUI window, click the "Выберите Файлы" (Select Files) button.
4. Select and Order Files:
Choose the three JSON translation files in the following order:
File 1: The JSON file with the NEW target language translations (e.g., CP_new_en.json).
File 2: The JSON file with the OLD target language translations (e.g., CP_old_en.json).
File 3: The JSON file with the OLD source/reference language translations (e.g., CP_old_ru.json).
5. Choose Output:
Select a name and location to save the updated JSON translation file.
When I double-click it, a black command window appears, then it asks me to select a json file, and I select “content.json”. But the window closes, and I don't see any changes...
2) Download and run Transtar
3) Drop your mod folder (or just the CP folder) into the Transtar window.
4) Click Extract (if an error pops up, you have an error in the file and it needs to be fixed) (If everything was successful, the programme will give you the NameMod dict folder).
5) Run CP_to_I18n.py and specify the CP.json file in the NameMod dict.
6) Go back to Transtar and click Generate.
7) Get the NameMod translation folder (these are already the mod files converted to i18n)
8) Throw the files from this folder with replacement in the folder of our mod.
9) Profit!!!!!11111
First, understanding how to use "transtar" will make it easier for me to understand your script (it's fantastic!).
In your 5 step, after running "CP_to_I18n.py" and selecting CP.json, two JSON files will be saved. The first JSON file still needs to keep the same name: CP.json, in order to use "transtar's" Generate function.
The second JSON file should be saved as default.json in the i18n folder.
Thanks again!
Let me know if you have any other questions or need further assistance.
Check it out. (added 9 i18n keys for item descriptions)
I also added a Russian translation for myself.
The items themselves remain in English, because if you translate their names, everything will break.
Процентов где-то 85% на русском
Сверху на ориг англ мод поставь.
https://www.nexusmods.com/stardewvalley/mods/7078?tab=description
I didn't touch the event files, they contain text and can be found in the path. You can also move them to i18n if you want. But my programme didn't capture them, so I decided not to touch them.
OpenFireMine.xnb also contains the text of the events, if necessary use xnbcli to unpack them.
OpenFire(SVE)\OpenFire\[CP] OpenFire\assets\Events\ (files 0, 2, 4, 6-1, 6-2, 8) and OpenFireMine.xnb
The English version of this mod is different, it made edits to the content file, it can also be done in i18n, but there will be differences in the lines.
https://www.nexusmods.com/stardewvalley/mods/19405
https://www.nexusmods.com/stardewvalley/mods/18109
@LekhaPridiKatkuZatashchi
It's just not very convenient to communicate here.
I'll have to clarify the i18n key naming issues. For your convenience.
Did I do something wrong? I saw you mentioned something about a small mistake in the files, is that why this happened? Can you maybe tell me how to fix it so I can do it myself? :')
Thanks anyways for even making these!
你能翻译这个模块吗?我真的很想要它。
https://www.nexusmods.com/stardewvalley/mods/22490