diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2017-08-18 15:22:37 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2017-08-18 15:22:37 +0100 |
commit | 06fdabb7ac1834823c6ecc4bebb94b13da5cf03e (patch) | |
tree | 5e3e368455f15ecfb3d8c05329f1ba8a417f27e6 /mesonbuild/scripts/yelphelper.py | |
parent | 62aabb5a8be90467603b1348d8ae4c0847bc5d1e (diff) | |
download | meson-06fdabb7ac1834823c6ecc4bebb94b13da5cf03e.zip meson-06fdabb7ac1834823c6ecc4bebb94b13da5cf03e.tar.gz meson-06fdabb7ac1834823c6ecc4bebb94b13da5cf03e.tar.bz2 |
Support LINGUAS for gnome.yelp() languages
Listing all languages inside meson.build for the Yelp-based manual
localisation is error-prone, and it also requires parsing and modifying
Meson files from external tools.
Just like we do for i18n, we can use an ancillary `LINGUAS` file in the
help source sub-directory to list all the help languages.
Diffstat (limited to 'mesonbuild/scripts/yelphelper.py')
-rw-r--r-- | mesonbuild/scripts/yelphelper.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py index 978a870..f8c9f8c 100644 --- a/mesonbuild/scripts/yelphelper.py +++ b/mesonbuild/scripts/yelphelper.py @@ -29,6 +29,22 @@ parser.add_argument('--media', dest='media', default='') parser.add_argument('--langs', dest='langs', default='') parser.add_argument('--symlinks', type=bool, dest='symlinks', default=False) +def read_linguas(src_sub): + # Syntax of this file is documented here: + # https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html + linguas = os.path.join(src_sub, 'LINGUAS') + try: + langs = [] + with open(linguas) as f: + for line in f: + line = line.strip() + if line and not line.startswith('#'): + langs += line.split() + return langs + except (FileNotFoundError, PermissionError): + print('Could not find file LINGUAS in {}'.format(src_sub)) + return [] + def build_pot(srcdir, project_id, sources): # Must be relative paths sources = [os.path.join('C', source) for source in sources] @@ -108,6 +124,9 @@ def run(args): build_subdir = os.path.join(os.environ['MESON_BUILD_ROOT'], options.subdir) abs_sources = [os.path.join(src_subdir, 'C', source) for source in sources] + if not langs: + langs = read_linguas(src_subdir) + if options.command == 'pot': build_pot(src_subdir, options.project_id, sources) elif options.command == 'update-po': |