From eabc8534b0018ac163394fdf6253a41c0fbadacb Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Wed, 17 Jun 2020 13:11:14 +0200 Subject: [PATCH] i18n Python scripts: define the list of basic categories at the top Introduce a BASIC_CATEGORIES variable at the top of python3-flightgear/flightgear/meta/i18n.py that lists all categories handled by BasicL10NResourceManager. Since currently all of our translation files can be handled this way (the XML master files all have a flat structure), we only need to say BASIC_CATEGORIES = CATEGORIES. With this change, adding a new basic category such as 'weather-scenarios' only requires one to add it to CATEGORIES. --- python3-flightgear/flightgear/meta/i18n.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python3-flightgear/flightgear/meta/i18n.py b/python3-flightgear/flightgear/meta/i18n.py index 066f71b..2998009 100644 --- a/python3-flightgear/flightgear/meta/i18n.py +++ b/python3-flightgear/flightgear/meta/i18n.py @@ -66,6 +66,10 @@ dummyLogger = DummyLogger() # Not including "atc", because it has no translation. Please keep this sorted. CATEGORIES = ("menu", "options", "sys", "tips") +# BASIC_CATEGORIES lists all categories handled by BasicL10NResourceManager. +# The corresponding master files must have a flat structure where each +# translatable string is found in a direct child of the element. +BASIC_CATEGORIES = CATEGORIES # Directory name for the default (master) translation DEFAULT_LANG_DIR = "default" # Root of the base name for the default output files (XLIFF...) @@ -1699,7 +1703,7 @@ registerFormatHandler("xliff", XliffFormatHandler) # Could also be a dict def L10nResMgrForCat(category): """Map from category/resource name to L10NResourceManager class.""" - if category in ("menu", "options", "sys", "tips"): + if category in BASIC_CATEGORIES: return BasicL10NResourceManager else: assert False, "unexpected category: {!r}".format(category)