diff --git a/Data/data/i18n/launcher/en-GB.i18n b/Data/system/app/Launcher/i18n/en-GB.i18n similarity index 100% rename from Data/data/i18n/launcher/en-GB.i18n rename to Data/system/app/Launcher/i18n/en-GB.i18n diff --git a/Data/data/i18n/launcher/en-US.i18n b/Data/system/app/Launcher/i18n/en-US.i18n similarity index 100% rename from Data/data/i18n/launcher/en-US.i18n rename to Data/system/app/Launcher/i18n/en-US.i18n diff --git a/Data/data/i18n/launcher/fr-FR.i18n b/Data/system/app/Launcher/i18n/fr-FR.i18n similarity index 100% rename from Data/data/i18n/launcher/fr-FR.i18n rename to Data/system/app/Launcher/i18n/fr-FR.i18n diff --git a/Data/data/i18n/launcher/nl-BE.i18n b/Data/system/app/Launcher/i18n/nl-BE.i18n similarity index 100% rename from Data/data/i18n/launcher/nl-BE.i18n rename to Data/system/app/Launcher/i18n/nl-BE.i18n diff --git a/Data/data/i18n/launcher/nl-NL.i18n b/Data/system/app/Launcher/i18n/nl-NL.i18n similarity index 100% rename from Data/data/i18n/launcher/nl-NL.i18n rename to Data/system/app/Launcher/i18n/nl-NL.i18n diff --git a/Data/data/i18n/core/en-GB.i18n b/Data/system/i18n/core/en-GB.i18n similarity index 100% rename from Data/data/i18n/core/en-GB.i18n rename to Data/system/i18n/core/en-GB.i18n diff --git a/Data/data/i18n/core/en-US.i18n b/Data/system/i18n/core/en-US.i18n similarity index 100% rename from Data/data/i18n/core/en-US.i18n rename to Data/system/i18n/core/en-US.i18n diff --git a/Data/data/i18n/core/fr-FR.i18n b/Data/system/i18n/core/fr-FR.i18n similarity index 100% rename from Data/data/i18n/core/fr-FR.i18n rename to Data/system/i18n/core/fr-FR.i18n diff --git a/Data/data/i18n/core/nl-BE.i18n b/Data/system/i18n/core/nl-BE.i18n similarity index 100% rename from Data/data/i18n/core/nl-BE.i18n rename to Data/system/i18n/core/nl-BE.i18n diff --git a/Data/data/i18n/core/nl-NL.i18n b/Data/system/i18n/core/nl-NL.i18n similarity index 100% rename from Data/data/i18n/core/nl-NL.i18n rename to Data/system/i18n/core/nl-NL.i18n diff --git a/Tactility/Include/Tactility/i18n/CoreTextResources.h b/Tactility/Include/Tactility/i18n/CoreTextResources.h new file mode 100644 index 00000000..591664cb --- /dev/null +++ b/Tactility/Include/Tactility/i18n/CoreTextResources.h @@ -0,0 +1,17 @@ +#pragma once + +// WARNING: This file is auto-generated. Do not edit manually. + +namespace tt::i18n::core { + +enum class Text { + OK = 0, + YES = 1, + NO = 2, + CANCEL = 3, + RETRY = 4, + CLOSE = 5, + OPEN = 6, +}; + +} diff --git a/Tactility/Private/Tactility/app/launcher/TextResources.h b/Tactility/Private/Tactility/app/launcher/TextResources.h new file mode 100644 index 00000000..6bfdf684 --- /dev/null +++ b/Tactility/Private/Tactility/app/launcher/TextResources.h @@ -0,0 +1,13 @@ +#pragma once + +// WARNING: This file is auto-generated. Do not edit manually. + +namespace tt::app::launcher::i18n { + +enum class Text { + APPS = 0, + FILES = 1, + SETTINGS = 2, +}; + +} diff --git a/Translations/generate-all.py b/Translations/generate-all.py index 7cf778cb..6963ff29 100644 --- a/Translations/generate-all.py +++ b/Translations/generate-all.py @@ -1,12 +1,30 @@ import os +from pathlib import Path -def generate(csvFile, headerFile, headerNamespace, dataPath): - if os.path.isfile(csvFile): - print(f"Generating {headerFile}") - os.system(f"python generate.py {csvFile} {headerFile} {headerNamespace} {dataPath}") +def get_project_root(): + return Path(__file__).parent.parent.resolve() + +def generate(csv_file, header_file, header_namespace, data_path): + csv_file_path = f"{get_project_root()}/Translations/{csv_file}" + if os.path.isfile(csv_file_path): + print(f"Processing {csv_file}") + script_path = f"{get_project_root()}/Translations/generate.py" + os.system(f"python {script_path} {csv_file} {header_file} {header_namespace} {data_path}") else: - print(f"Skipping {headerFile} (not found)") + print(f"Skipping {csv_file} (not found)") if __name__ == "__main__": - generate("system.csv", "../Tactility/Include/Tactility/i18n/Core.h", "tt::i18n::core", "../Data/data/i18n/core") - generate("launcher.csv", "../Tactility/Include/Tactility/i18n/Launcher.h", "tt::i18n::launcher", "../Data/data/i18n/launcher") + # Core translations + generate( + "system.csv", + "Tactility/Include/Tactility/i18n/CoreTextResources.h", + "tt::i18n::core", + "Data/system/i18n/core" + ) + # Launcher app + generate( + "launcher.csv", + "Tactility/Private/Tactility/app/launcher/TextResources.h", + "tt::app::launcher::i18n", + "Data/system/app/Launcher/i18n" + ) diff --git a/Translations/generate.py b/Translations/generate.py index 166348a8..7b0fe210 100644 --- a/Translations/generate.py +++ b/Translations/generate.py @@ -1,7 +1,11 @@ import csv import sys +from pathlib import Path from typing import List +def get_project_root(): + return Path(__file__).parent.parent.resolve() + def load_csv(path: str, delimiter: str = ",", quotechar: str = '"', encoding: str = "utf-8", skip_header: bool = False) -> List[List[str]]: """ Load a CSV file into a list of rows, where each row is a list of strings. @@ -45,7 +49,7 @@ def close_i18n_files(files): for file in files: file.close() -def generate_header(filepath, rows, namespace): +def generate_header(filepath, namespace, rows): file = open(filepath, "w") file.write("#pragma once\n\n") file.write("// WARNING: This file is auto-generated. Do not edit manually.\n\n") @@ -74,15 +78,16 @@ if __name__ == "__main__": if len(sys.argv) != 5: print_help() sys.exit() - csv_file = sys.argv[1] - header_path = sys.argv[2] + project_root_path = get_project_root() + csv_file = f"{project_root_path}/Translations/{sys.argv[1]}" + header_path = f"{project_root_path}/{sys.argv[2]}" header_namespace = sys.argv[3] - i18n_path = sys.argv[4] + i18n_path = f"{project_root_path}/{sys.argv[4]}" rows = load_csv(csv_file) if len(rows) == 0: print("Error: CSV file is empty.") sys.exit(1) - generate_header(header_path, rows, header_namespace) + generate_header(header_path, header_namespace, rows) i18n_files = open_i18n_files(rows[0], i18n_path) for i in range(0, len(i18n_files)): i18n_file = i18n_files[i]