From d156c8c99ed8226e19fd320dc1e18772ac11dbd2 Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Thu, 18 Jun 2020 17:20:24 +0200 Subject: [PATCH] [apps/i18n] Added country support Added a list of supported countries to I18n, and created messages for each country's names in each language. Change-Id: I1b887d75da980d99e21f89cc151249e42c78de88 --- apps/Makefile | 2 +- apps/i18n.py | 24 ++++++++++++++++++++---- apps/shared.de.i18n | 11 +++++++++++ apps/shared.en.i18n | 11 +++++++++++ apps/shared.es.i18n | 11 +++++++++++ apps/shared.fr.i18n | 11 +++++++++++ apps/shared.it.i18n | 11 +++++++++++ apps/shared.nl.i18n | 11 +++++++++++ apps/shared.pt.i18n | 11 +++++++++++ build/config.mak | 1 + escher/include/escher/i18n.h | 2 +- 11 files changed, 100 insertions(+), 6 deletions(-) diff --git a/apps/Makefile b/apps/Makefile index bd7195041..a76386d21 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -71,7 +71,7 @@ $(eval $(call rule_for, \ I18N, \ apps/i18n.cpp, \ $(i18n_files), \ - $$(PYTHON) apps/i18n.py --codepoints $(code_points) --header $$(subst .cpp,.h,$$@) --implementation $$@ --locales $$(EPSILON_I18N) --files $$^ --generateISO6391locales $$(EPSILON_GETOPT), \ + $$(PYTHON) apps/i18n.py --codepoints $(code_points) --header $$(subst .cpp,.h,$$@) --implementation $$@ --locales $$(EPSILON_I18N) --countries $$(EPSILON_COUNTRIES) --files $$^ --generateISO6391locales $$(EPSILON_GETOPT), \ global \ )) diff --git a/apps/i18n.py b/apps/i18n.py index a6130e49a..6f9dddcc9 100644 --- a/apps/i18n.py +++ b/apps/i18n.py @@ -17,6 +17,7 @@ parser = argparse.ArgumentParser(description="Process some i18n files.") parser.add_argument('--header', help='the .h file to generate') parser.add_argument('--implementation', help='the .cpp file to generate') parser.add_argument('--locales', nargs='+', help='locale to actually generate') +parser.add_argument('--countries', nargs='+', help='countries to actually generate') parser.add_argument('--codepoints', help='the code_points.h file') parser.add_argument('--files', nargs='+', help='an i18n file') parser.add_argument('--generateISO6391locales', type=int, nargs='+', help='whether to generate the ISO6391 codes for the languages (for instance "en" for english)') @@ -114,7 +115,7 @@ def parse_codepoints(file): codepoints = parse_codepoints(args.codepoints) -def print_header(data, path, locales): +def print_header(data, path, locales, countries): f = open(path, "w") f.write("#ifndef APPS_I18N_H\n") f.write("#define APPS_I18N_H\n\n") @@ -122,6 +123,7 @@ def print_header(data, path, locales): f.write("#include \n\n") f.write("namespace I18n {\n\n") f.write("constexpr static int NumberOfLanguages = %d;\n\n" % len(locales)) + f.write("constexpr static int NumberOfCountries = %d;\n\n" % len(countries)) # Messages enumeration f.write("enum class Message : uint16_t {\n") @@ -135,10 +137,10 @@ def print_header(data, path, locales): f.write("};\n\n") # Languages enumeration - f.write("enum class Language : uint16_t {\n") + f.write("enum class Language : uint8_t {\n") index = 0 for locale in locales: - f.write(" " + locale.upper() + (" = 0" if (index < 1) else "") +",\n") + f.write(" " + locale.upper() + (" = 0" if (index < 1) else "") + ",\n") index = index + 1 f.write("};\n\n") @@ -155,6 +157,20 @@ def print_header(data, path, locales): f.write(" Message::LanguageISO6391" + locale.upper() + ",\n") f.write("};\n\n") + # Countries enumeration + f.write("enum class Country : uint8_t {\n") + index = 0 + for country in countries: + f.write(" " + country.upper() + (" = 0" if (index < 1) else "") + ",\n") + index += 1 + f.write("};\n\n") + + # Country names + f.write("constexpr const Message CountryNames[NumberOfCountries] = {\n"); + for country in countries: + f.write(" Message::Country" + country.upper() + ",\n") + f.write("};\n\n") + f.write("}\n\n") f.write("#endif\n") f.close() @@ -226,6 +242,6 @@ def print_implementation(data, path, locales): data = parse_files(args.files) if args.header: - print_header(data, args.header, args.locales) + print_header(data, args.header, args.locales, args.countries) if args.implementation: print_implementation(data, args.implementation, args.locales) diff --git a/apps/shared.de.i18n b/apps/shared.de.i18n index b868b5395..df2df5f3d 100644 --- a/apps/shared.de.i18n +++ b/apps/shared.de.i18n @@ -12,6 +12,17 @@ Cancel = "Abbrechen" ClearColumn = "Spalte löschen" ColumnOptions = "Optionen der Spalte" CopyColumnInList = "Die Spalte in einer Liste kopieren" +Country = "Land" +CountryCA = "Kanada " +CountryDE = "Deutschland " +CountryES = "Spanien " +CountryFR = "Frankreich " +CountryGB = "Vereinigtes Königreich " +CountryIT = "Italien " +CountryNL = "Niederlande " +CountryPT = "Portugal " +CountryUS = "Vereinigte Staaten " +CountryWW = "International " DataNotSuitable = "Daten nicht geeignet" DataTab = "Daten" DefaultSetting = "Grundeinstellung" diff --git a/apps/shared.en.i18n b/apps/shared.en.i18n index 2ddbf867b..589744078 100644 --- a/apps/shared.en.i18n +++ b/apps/shared.en.i18n @@ -12,6 +12,17 @@ Cancel = "Cancel" ClearColumn = "Clear column" ColumnOptions = "Column options" CopyColumnInList = "Export the column to a list" +Country = "Country" +CountryCA = "Canada " +CountryDE = "Germany " +CountryES = "Spain " +CountryFR = "France " +CountryGB = "United Kingdom " +CountryIT = "Italy " +CountryNL = "Netherlands " +CountryPT = "Portugal " +CountryUS = "United States " +CountryWW = "International " DataNotSuitable = "Data not suitable" DataTab = "Data" DefaultSetting = "Basic settings" diff --git a/apps/shared.es.i18n b/apps/shared.es.i18n index 339be457f..8b59ee580 100644 --- a/apps/shared.es.i18n +++ b/apps/shared.es.i18n @@ -12,6 +12,17 @@ Cancel = "Cancelar" ClearColumn = "Borrar la columna" ColumnOptions = "Opciones de la columna" CopyColumnInList = "Copiar la columna en una lista" +Country = "País" +CountryCA = "Canadá " +CountryDE = "Alemania " +CountryES = "España " +CountryFR = "Francia " +CountryGB = "Reino Unido " +CountryIT = "Italia " +CountryNL = "Países Bajos " +CountryPT = "Portugal " +CountryUS = "Estados Unidos " +CountryWW = "Internacional " DataNotSuitable = "Datos no adecuados" DataTab = "Datos" DefaultSetting = "Ajustes básicos" diff --git a/apps/shared.fr.i18n b/apps/shared.fr.i18n index 002e27297..c6e9ce7cf 100644 --- a/apps/shared.fr.i18n +++ b/apps/shared.fr.i18n @@ -12,6 +12,17 @@ Cancel = "Annuler" ClearColumn = "Effacer la colonne" ColumnOptions = "Options de la colonne" CopyColumnInList = "Copier la colonne dans une liste" +Country = "Pays" +CountryCA = "Canada " +CountryDE = "Allemagne " +CountryES = "Espagne " +CountryFR = "France " +CountryGB = "Royaume-Uni " +CountryIT = "Italie " +CountryNL = "Pays-Bas " +CountryPT = "Portugal " +CountryUS = "Etats-Unis " +CountryWW = "International " DataNotSuitable = "Les données ne conviennent pas" DataTab = "Données" DefaultSetting = "Réglages de base" diff --git a/apps/shared.it.i18n b/apps/shared.it.i18n index b18957f67..579f7fcc3 100644 --- a/apps/shared.it.i18n +++ b/apps/shared.it.i18n @@ -12,6 +12,17 @@ Cancel = "Annullare" ClearColumn = "Cancella la colonna" ColumnOptions = "Opzioni colonna" CopyColumnInList = "Copia colonna in una lista" +Country = "Paese" +CountryCA = "Canada " +CountryDE = "Germania " +CountryES = "Spagna " +CountryFR = "Francia " +CountryGB = "Regno Unito " +CountryIT = "Italia " +CountryNL = "Paesi Bassi " +CountryPT = "Portogallo " +CountryUS = "Stati Uniti " +CountryWW = "Internazionale " DataNotSuitable = "I dati non sono adeguati" DataTab = "Dati" DefaultSetting = "Impostazioni di base" diff --git a/apps/shared.nl.i18n b/apps/shared.nl.i18n index a2f65a935..b12190ca1 100644 --- a/apps/shared.nl.i18n +++ b/apps/shared.nl.i18n @@ -12,6 +12,17 @@ Cancel = "Annuleer" ClearColumn = "Wis kolom" ColumnOptions = "Kolomopties" CopyColumnInList = "Exporteer de kolom naar een lijst" +Country = "Land" +CountryCA = "Canada " +CountryDE = "Duitsland " +CountryES = "Spanje " +CountryFR = "Frankrijk " +CountryGB = "Verenigd Koninkrijk " +CountryIT = "Italië " +CountryNL = "Nederland " +CountryPT = "Portugal " +CountryUS = "Verenigde Staten " +CountryWW = "Internationale " DataNotSuitable = "Gegevens niet geschikt" DataTab = "Gegevens" DefaultSetting = "Standaardinstelling" diff --git a/apps/shared.pt.i18n b/apps/shared.pt.i18n index d3cfd3249..036d6e99e 100644 --- a/apps/shared.pt.i18n +++ b/apps/shared.pt.i18n @@ -12,6 +12,17 @@ Cancel = "Cancelar" ClearColumn = "Excluir coluna" ColumnOptions = "Opções de coluna" CopyColumnInList = "Copiar a coluna para uma lista" +Country = "País" +CountryCA = "Canadá " +CountryDE = "Alemanha " +CountryES = "Espanha " +CountryFR = "França " +CountryGB = "Reino Unido " +CountryIT = "Itália " +CountryNL = "Países Baixos " +CountryPT = "Portugal " +CountryUS = "Estados Unidos " +CountryWW = "Internacional " DataNotSuitable = "Dados não adequados" DataTab = "Dados" DefaultSetting = "Configurações básicas" diff --git a/build/config.mak b/build/config.mak index e6b20d515..e8e8074c6 100644 --- a/build/config.mak +++ b/build/config.mak @@ -6,6 +6,7 @@ DEBUG ?= 0 EPSILON_VERSION ?= 14.4.1 EPSILON_APPS ?= calculation graph code statistics probability solver sequence regression settings EPSILON_I18N ?= en fr nl pt it de es +EPSILON_COUNTRIES ?= CA DE ES FR GB IT NL PT US WW EPSILON_GETOPT ?= 0 EPSILON_TELEMETRY ?= 0 ESCHER_LOG_EVENTS_BINARY ?= 0 diff --git a/escher/include/escher/i18n.h b/escher/include/escher/i18n.h index 301b7ef9b..11de7fddb 100644 --- a/escher/include/escher/i18n.h +++ b/escher/include/escher/i18n.h @@ -5,7 +5,7 @@ namespace I18n { enum class Message : uint16_t; - enum class Language : uint16_t; + enum class Language : uint8_t; const char * translate(Message m); int numberOfLanguages(); }