Commit ee2b88cc authored by Claude Paroz's avatar Claude Paroz

Fixes #109 - gettext.args Meson variable can be a list or a string

parent 5bed797f
......@@ -29,6 +29,28 @@ from stats.doap import update_doap_infos
from people.models import Person
from languages.models import Language
# These args should be kept in sync with
# https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/i18n.py#L25
GLIB_PRESET = (
'--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',
)
# Standard Django slug validation but also accept '+' (for gtk+)
slug_re = re.compile(r'^[-\+a-zA-Z0-9_]+\Z')
......@@ -803,30 +825,10 @@ class Domain(models.Model):
makefile = utils.MakefileWrapper.find_file(branch, [vcs_path], file_name='meson.build')
if makefile:
if makefile.read_variable('gettext.preset') == 'glib' or not makefile.readable:
# 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',
])
pot_command.extend(GLIB_PRESET)
extra_args = makefile.read_variable('gettext.args')
if extra_args:
pot_command.extend(extra_args)
pot_command.extend([extra_args] if isinstance(extra_args, str) else extra_args)
datadirs = makefile.read_variable('gettext.data_dirs')
if datadirs:
env['GETTEXTDATADIRS'] = ':'.join(
......
i18n.gettext(meson.project_name(),
preset: 'glib',
args: '--keyword=Description'
)
......@@ -16,8 +16,8 @@ from django.test.utils import override_settings
from common.utils import run_shell_command
from stats.models import (
Module, Domain, Branch, Release, CategoryName, Statistics, FakeLangStatistics,
Information, UnableToCommit
GLIB_PRESET, Module, Domain, Branch, Release, CategoryName, Statistics,
FakeLangStatistics, Information, UnableToCommit
)
from stats import utils
from languages.models import Language
......@@ -526,7 +526,9 @@ class DomainTests(TestModuleBase):
(['xgettext', '--files-from', 'POTFILES.in', '--directory',
os.path.join(settings.SCRATCHDIR, 'git', 'testmodule'),
'--from-code', 'utf-8',
'--add-comments', '--output', 'testmodule.pot', '--msgid-bugs-address',
'--add-comments', '--output', 'testmodule.pot'] + list(GLIB_PRESET) +
['--keyword=Description',
'--msgid-bugs-address',
'https://gitlab.gnome.org/GNOME/testmodule/issues'],
{'GETTEXTDATADIRS': os.path.dirname(utils.ITS_DATA_DIR)}
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment