[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
This commit is contained in:
Gabriel Ozouf
2020-06-18 17:20:24 +02:00
committed by Émilie Feral
parent 87591369b8
commit d156c8c99e
11 changed files with 100 additions and 6 deletions

View File

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

View File

@@ -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 <escher.h>\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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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();
}