Stardew Valley

File information

Last updated

Original upload

Created by

AlexGoD

Uploaded by

darthalex2014

Virus scan

Safe to use

About this mod

Do you have a mod with 500+ lines and translators crying?
Do you want to update your old translation for the new version of the mod?

Requirements
Permissions and credits
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. (Need Transtar)



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 Translated Files (Объединить переведенные файлы):
    • Цель: Аналогично "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 для генерации окончательных переведенных файлов мода.
  • Это руководство предоставляет базовый обзор. Вам может потребоваться немного адаптировать процесс или имена файлов в зависимости от конкретных требований вашего мода.


Outdated instructions (for the old version)
Spoiler:  
Show

My selection of Python scripts
 for working with Transtar (I allow their use and modification for your needs, you can use them as ideas or inspiration).
1) 1_key_translation.py - removes everything from json except key and original (carefully overwrites the CP.json file)
2) 2_only_translation.py - leaves only translation (creates a CP_cleaned.json file) (use it to shove manually into GPT or Gemini, or another translator with less text).
3) 3_translation_to_key_and_OLDtranslation.py - takes the translation from CP_cleaned.json and replaces the lines in CP.json, creating a new file CP_NEW.json (When I have done a complete translation of CP_cleaned.json, I transfer the translation to CP_NEW.json).
4) 4_translation_to_CP - Takes the translation from CP_NEW.json and shoves it into the original CP.json file (not modified 1_key_translation.py) (First select CP.json, then CP_NEW.json) (You get a ready CP.json file, you just need to click Generate in Transtar and get the finished translation).

Bonus
5) CP_to_I18n.py - creates a simple i18n from CP.json. (2 files, 1 is a duplicate of CP.json with i18n keys, for generating through Transtar the mod version with i18n, the 2nd file is default.json with i18n keys (you may need to use jsonlint for the beauty of the json file).
6) original_to_cleaned.py - same as 1_key_translation.py, but gets "translation" instead of "original"
7) Old_translate_to_New.py (This Python script is designed to help you update translations in JSON files based on changes in different versions.)



instruction for CP_to_I18n.py
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