Locale
This commit is contained in:
@@ -141,14 +141,40 @@ def processLanguageList():
|
||||
os.makedirs(os.path.dirname(outputFile), exist_ok=True)
|
||||
with open(outputFile, "wb") as f:
|
||||
f.write(langBuffer)
|
||||
|
||||
|
||||
|
||||
# Write out the language keys header file
|
||||
outputFile = os.path.join(args.headers_dir, "locale", "language", "keys.h")
|
||||
os.makedirs(os.path.dirname(outputFile), exist_ok=True)
|
||||
with open(outputFile, "w") as f:
|
||||
f.write(headerKeys)
|
||||
|
||||
# Generate language list.
|
||||
headerLocale = "#pragma once\n#include \"locale/localeinfo.h\"\n\n"
|
||||
headerLocale += "typedef enum {\n"
|
||||
count = 0
|
||||
headerLocale += f" DUSK_LOCALE_NULL = {count},\n"
|
||||
count += 1
|
||||
for lang in LANGUAGE_DATA:
|
||||
langKey = lang.replace('-', '_').replace(' ', '_').upper()
|
||||
headerLocale += f" DUSK_LOCALE_{langKey} = {count},\n"
|
||||
count += 1
|
||||
headerLocale += f" DUSK_LOCALE_COUNT = {count}\n"
|
||||
headerLocale += "} dusklocale_t;\n\n"
|
||||
|
||||
headerLocale += f"static const localeinfo_t LOCALE_INFOS[DUSK_LOCALE_COUNT] = {{\n"
|
||||
for lang in LANGUAGE_DATA:
|
||||
langKey = lang.replace('-', '_').replace(' ', '_').upper()
|
||||
headerLocale += f" [DUSK_LOCALE_{langKey}] = {{\n"
|
||||
headerLocale += f" .file = \"{lang}\"\n"
|
||||
headerLocale += f" }},\n"
|
||||
headerLocale += "};\n"
|
||||
|
||||
# Write out the locale enum header file
|
||||
outputFile = os.path.join(args.headers_dir, "locale", "locale.h")
|
||||
os.makedirs(os.path.dirname(outputFile), exist_ok=True)
|
||||
with open(outputFile, "w") as f:
|
||||
f.write(headerLocale)
|
||||
|
||||
return {
|
||||
'files': files
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user