[damned-lies] Extend xgettext args when meson.build uses the glib preset



commit 2af1fe383135584203b94f217fce6eda4cecbf6e
Author: Claude Paroz <claude 2xlibre net>
Date:   Sun Aug 13 23:02:26 2017 +0200

    Extend xgettext args when meson.build uses the glib preset

 stats/models.py |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index bcd5b1d..dfe9eba 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -828,12 +828,35 @@ class Domain(models.Model):
                                                 for path in self.extra_its_dirs.split(':')]
                 )
             # Parse and use content from: "XGETTEXT_OPTIONS = --keyword=_ --keyword=N_"
-            kwds_vars = None
             makefile = utils.MakefileWrapper.find_file([vcs_path], file_name='Makevars')
             if makefile:
                 kwds_vars = makefile.read_variable('XGETTEXT_OPTIONS')
-            if kwds_vars:
-                pot_command.extend(kwds_vars.split())
+                if kwds_vars:
+                    pot_command.extend(kwds_vars.split())
+            else:
+                makefile = utils.MakefileWrapper.find_file([vcs_path], file_name='meson.build')
+                if makefile and makefile.read_variable('preset') == 'glib':
+                    # These args should be kept in sync with
+                    # https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/i18n.py#L25
+                    pot_command.extend([
+                        '--keyword=_',
+                        '--keyword=N_',
+                        '--keyword=C_:1c,2',
+                        '--keyword=NC_:1c,2',
+                        '--keyword=g_dcgettext:2',
+                        '--keyword=g_dngettext:2,3',
+                        '--keyword=g_dpgettext2:2c,3',
+
+                        '--flag=N_:1:pass-c-format',
+                        '--flag=C_:2:pass-c-format',
+                        '--flag=NC_:2:pass-c-format',
+                        '--flag=g_dngettext:2:pass-c-format',
+                        '--flag=g_strdup_printf:1:c-format',
+                        '--flag=g_string_printf:2:c-format',
+                        '--flag=g_string_append_printf:2:c-format',
+                        '--flag=g_error_new:3:c-format',
+                        '--flag=g_set_error:4:c-format',
+                    ])
             # Added last as some chars in it may disturb CLI parsing
             bugs_url = self.module.get_bugs_enter_url()
             if bugs_url:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]