Move files around

This commit is contained in:
Ken Van Hoeylandt 2025-08-24 17:06:35 +02:00
parent 9fd344be1b
commit 3476ac1bf1
14 changed files with 65 additions and 12 deletions

View File

@ -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,
};
}

View File

@ -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,
};
}

View File

@ -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"
)

View File

@ -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]