We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
i18n module does not seem to respect MESON_INSTALL_QUIET environment variable
**Describe the bug**

When using `meson install --quiet`, there's still output generated by what I presume is gettext:

```
Installing /root/build/po/be.gmo to /root/dest/usr/share/locale/be/LC_MESSAGES/systemd.mo
Installing /root/build/po/be@latin.gmo to /root/dest/usr/share/locale/be@latin/LC_MESSAGES/systemd.mo
Installing /root/build/po/bg.gmo to /root/dest/usr/share/locale/bg/LC_MESSAGES/systemd.mo
Installing /root/build/po/ca.gmo to /root/dest/usr/share/locale/ca/LC_MESSAGES/systemd.mo
Installing /root/build/po/cs.gmo to /root/dest/usr/share/locale/cs/LC_MESSAGES/systemd.mo
Installing /root/build/po/da.gmo to /root/dest/usr/share/locale/da/LC_MESSAGES/systemd.mo
Installing /root/build/po/de.gmo to /root/dest/usr/share/locale/de/LC_MESSAGES/systemd.mo
Installing /root/build/po/el.gmo to /root/dest/usr/share/locale/el/LC_MESSAGES/systemd.mo
Installing /root/build/po/es.gmo to /root/dest/usr/share/locale/es/LC_MESSAGES/systemd.mo
Installing /root/build/po/fr.gmo to /root/dest/usr/share/locale/fr/LC_MESSAGES/systemd.mo
Installing /root/build/po/gl.gmo to /root/dest/usr/share/locale/gl/LC_MESSAGES/systemd.mo
Installing /root/build/po/hr.gmo to /root/dest/usr/share/locale/hr/LC_MESSAGES/systemd.mo
Installing /root/build/po/hu.gmo to /root/dest/usr/share/locale/hu/LC_MESSAGES/systemd.mo
Installing /root/build/po/id.gmo to /root/dest/usr/share/locale/id/LC_MESSAGES/systemd.mo
Installing /root/build/po/it.gmo to /root/dest/usr/share/locale/it/LC_MESSAGES/systemd.mo
Installing /root/build/po/ja.gmo to /root/dest/usr/share/locale/ja/LC_MESSAGES/systemd.mo
Installing /root/build/po/ko.gmo to /root/dest/usr/share/locale/ko/LC_MESSAGES/systemd.mo
Installing /root/build/po/lt.gmo to /root/dest/usr/share/locale/lt/LC_MESSAGES/systemd.mo
Installing /root/build/po/pl.gmo to /root/dest/usr/share/locale/pl/LC_MESSAGES/systemd.mo
Installing /root/build/po/pt_BR.gmo to /root/dest/usr/share/locale/pt_BR/LC_MESSAGES/systemd.mo
Installing /root/build/po/ro.gmo to /root/dest/usr/share/locale/ro/LC_MESSAGES/systemd.mo
Installing /root/build/po/ru.gmo to /root/dest/usr/share/locale/ru/LC_MESSAGES/systemd.mo
Installing /root/build/po/sk.gmo to /root/dest/usr/share/locale/sk/LC_MESSAGES/systemd.mo
Installing /root/build/po/sr.gmo to /root/dest/usr/share/locale/sr/LC_MESSAGES/systemd.mo
Installing /root/build/po/sv.gmo to /root/dest/usr/share/locale/sv/LC_MESSAGES/systemd.mo
Installing /root/build/po/tr.gmo to /root/dest/usr/share/locale/tr/LC_MESSAGES/systemd.mo
Installing /root/build/po/uk.gmo to /root/dest/usr/share/locale/uk/LC_MESSAGES/systemd.mo
Installing /root/build/po/zh_CN.gmo to /root/dest/usr/share/locale/zh_CN/LC_MESSAGES/systemd.mo
Installing /root/build/po/zh_TW.gmo to /root/dest/usr/share/locale/zh_TW/LC_MESSAGES/systemd.mo
```

**To Reproduce**

```
git clone https://github.com/systemd/systemd.git
meson build
meson compile -C build
meson install -C build --quiet
```

**Expected behavior**

No output from gettext when --quiet is passed to `meson install`

**system parameters**

Should not be relevant to this bug. Let me know if I should add them. I'm running latest meson (0.56.0)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mesonbuild/scripts/gettext.py`
Content:
```
1 # Copyright 2016 The Meson development team
2 
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import os
16 import shutil
17 import argparse
18 import subprocess
19 from . import destdir_join
20 import typing as T
21 
22 parser = argparse.ArgumentParser()
23 parser.add_argument('command')
24 parser.add_argument('--pkgname', default='')
25 parser.add_argument('--datadirs', default='')
26 parser.add_argument('--langs', default='')
27 parser.add_argument('--localedir', default='')
28 parser.add_argument('--subdir', default='')
29 parser.add_argument('--extra-args', default='')
30 
31 def read_linguas(src_sub: str) -> T.List[str]:
32     # Syntax of this file is documented here:
33     # https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html
34     linguas = os.path.join(src_sub, 'LINGUAS')
35     try:
36         langs = []
37         with open(linguas) as f:
38             for line in f:
39                 line = line.strip()
40                 if line and not line.startswith('#'):
41                     langs += line.split()
42         return langs
43     except (FileNotFoundError, PermissionError):
44         print('Could not find file LINGUAS in {}'.format(src_sub))
45         return []
46 
47 def run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> int:
48     listfile = os.path.join(src_sub, 'POTFILES.in')
49     if not os.path.exists(listfile):
50         listfile = os.path.join(src_sub, 'POTFILES')
51         if not os.path.exists(listfile):
52             print('Could not find file POTFILES in %s' % src_sub)
53             return 1
54 
55     child_env = os.environ.copy()
56     if datadirs:
57         child_env['GETTEXTDATADIRS'] = datadirs
58 
59     ofile = os.path.join(src_sub, pkgname + '.pot')
60     return subprocess.call(['xgettext', '--package-name=' + pkgname, '-p', src_sub, '-f', listfile,
61                             '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args,
62                            env=child_env)
63 
64 def gen_gmo(src_sub: str, bld_sub: str, langs: T.List[str]) -> int:
65     for l in langs:
66         subprocess.check_call(['msgfmt', os.path.join(src_sub, l + '.po'),
67                                '-o', os.path.join(bld_sub, l + '.gmo')])
68     return 0
69 
70 def update_po(src_sub: str, pkgname: str, langs: T.List[str]) -> int:
71     potfile = os.path.join(src_sub, pkgname + '.pot')
72     for l in langs:
73         pofile = os.path.join(src_sub, l + '.po')
74         if os.path.exists(pofile):
75             subprocess.check_call(['msgmerge', '-q', '-o', pofile, pofile, potfile])
76         else:
77             subprocess.check_call(['msginit', '--input', potfile, '--output-file', pofile, '--locale', l, '--no-translator'])
78     return 0
79 
80 def do_install(src_sub: str, bld_sub: str, dest: str, pkgname: str, langs: T.List[str]) -> int:
81     for l in langs:
82         srcfile = os.path.join(bld_sub, l + '.gmo')
83         outfile = os.path.join(dest, l, 'LC_MESSAGES',
84                                pkgname + '.mo')
85         tempfile = outfile + '.tmp'
86         os.makedirs(os.path.dirname(outfile), exist_ok=True)
87         shutil.copy2(srcfile, tempfile)
88         os.replace(tempfile, outfile)
89         print('Installing %s to %s' % (srcfile, outfile))
90     return 0
91 
92 def run(args: T.List[str]) -> int:
93     options = parser.parse_args(args)
94     subcmd = options.command
95     langs = options.langs.split('@@') if options.langs else None
96     extra_args = options.extra_args.split('@@') if options.extra_args else []
97     subdir = os.environ.get('MESON_SUBDIR', '')
98     if options.subdir:
99         subdir = options.subdir
100     src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], subdir)
101     bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], subdir)
102 
103     if not langs:
104         langs = read_linguas(src_sub)
105 
106     if subcmd == 'pot':
107         return run_potgen(src_sub, options.pkgname, options.datadirs, extra_args)
108     elif subcmd == 'gen_gmo':
109         return gen_gmo(src_sub, bld_sub, langs)
110     elif subcmd == 'update_po':
111         if run_potgen(src_sub, options.pkgname, options.datadirs, extra_args) != 0:
112             return 1
113         return update_po(src_sub, options.pkgname, langs)
114     elif subcmd == 'install':
115         destdir = os.environ.get('DESTDIR', '')
116         dest = destdir_join(destdir, os.path.join(os.environ['MESON_INSTALL_PREFIX'],
117                                                   options.localedir))
118         if gen_gmo(src_sub, bld_sub, langs) != 0:
119             return 1
120         do_install(src_sub, bld_sub, dest, options.pkgname, langs)
121     else:
122         print('Unknown subcommand.')
123         return 1
124     return 0
125
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -86,7 +86,8 @@
         os.makedirs(os.path.dirname(outfile), exist_ok=True)
         shutil.copy2(srcfile, tempfile)
         os.replace(tempfile, outfile)
-        print('Installing %s to %s' % (srcfile, outfile))
+        if not os.getenv('MESON_INSTALL_QUIET', False):
+            print('Installing %s to %s' % (srcfile, outfile))
     return 0
 
 def run(args: T.List[str]) -> int:

{"golden_diff": "diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py\n--- a/mesonbuild/scripts/gettext.py\n+++ b/mesonbuild/scripts/gettext.py\n@@ -86,7 +86,8 @@\n         os.makedirs(os.path.dirname(outfile), exist_ok=True)\n         shutil.copy2(srcfile, tempfile)\n         os.replace(tempfile, outfile)\n-        print('Installing %s to %s' % (srcfile, outfile))\n+        if not os.getenv('MESON_INSTALL_QUIET', False):\n+            print('Installing %s to %s' % (srcfile, outfile))\n     return 0\n \n def run(args: T.List[str]) -> int:\n", "issue": "i18n module does not seem to respect MESON_INSTALL_QUIET environment variable\n**Describe the bug**\r\n\r\nWhen using `meson install --quiet`, there's still output generated by what I presume is gettext:\r\n\r\n```\r\nInstalling /root/build/po/be.gmo to /root/dest/usr/share/locale/be/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/be@latin.gmo to /root/dest/usr/share/locale/be@latin/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/bg.gmo to /root/dest/usr/share/locale/bg/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/ca.gmo to /root/dest/usr/share/locale/ca/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/cs.gmo to /root/dest/usr/share/locale/cs/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/da.gmo to /root/dest/usr/share/locale/da/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/de.gmo to /root/dest/usr/share/locale/de/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/el.gmo to /root/dest/usr/share/locale/el/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/es.gmo to /root/dest/usr/share/locale/es/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/fr.gmo to /root/dest/usr/share/locale/fr/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/gl.gmo to /root/dest/usr/share/locale/gl/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/hr.gmo to /root/dest/usr/share/locale/hr/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/hu.gmo to /root/dest/usr/share/locale/hu/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/id.gmo to /root/dest/usr/share/locale/id/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/it.gmo to /root/dest/usr/share/locale/it/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/ja.gmo to /root/dest/usr/share/locale/ja/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/ko.gmo to /root/dest/usr/share/locale/ko/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/lt.gmo to /root/dest/usr/share/locale/lt/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/pl.gmo to /root/dest/usr/share/locale/pl/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/pt_BR.gmo to /root/dest/usr/share/locale/pt_BR/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/ro.gmo to /root/dest/usr/share/locale/ro/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/ru.gmo to /root/dest/usr/share/locale/ru/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/sk.gmo to /root/dest/usr/share/locale/sk/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/sr.gmo to /root/dest/usr/share/locale/sr/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/sv.gmo to /root/dest/usr/share/locale/sv/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/tr.gmo to /root/dest/usr/share/locale/tr/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/uk.gmo to /root/dest/usr/share/locale/uk/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/zh_CN.gmo to /root/dest/usr/share/locale/zh_CN/LC_MESSAGES/systemd.mo\r\nInstalling /root/build/po/zh_TW.gmo to /root/dest/usr/share/locale/zh_TW/LC_MESSAGES/systemd.mo\r\n```\r\n\r\n**To Reproduce**\r\n\r\n```\r\ngit clone https://github.com/systemd/systemd.git\r\nmeson build\r\nmeson compile -C build\r\nmeson install -C build --quiet\r\n```\r\n\r\n**Expected behavior**\r\n\r\nNo output from gettext when --quiet is passed to `meson install`\r\n\r\n**system parameters**\r\n\r\nShould not be relevant to this bug. Let me know if I should add them. I'm running latest meson (0.56.0)\r\n\n", "before_files": [{"content": "# Copyright 2016 The Meson development team\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport shutil\nimport argparse\nimport subprocess\nfrom . import destdir_join\nimport typing as T\n\nparser = argparse.ArgumentParser()\nparser.add_argument('command')\nparser.add_argument('--pkgname', default='')\nparser.add_argument('--datadirs', default='')\nparser.add_argument('--langs', default='')\nparser.add_argument('--localedir', default='')\nparser.add_argument('--subdir', default='')\nparser.add_argument('--extra-args', default='')\n\ndef read_linguas(src_sub: str) -> T.List[str]:\n    # Syntax of this file is documented here:\n    # https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html\n    linguas = os.path.join(src_sub, 'LINGUAS')\n    try:\n        langs = []\n        with open(linguas) as f:\n            for line in f:\n                line = line.strip()\n                if line and not line.startswith('#'):\n                    langs += line.split()\n        return langs\n    except (FileNotFoundError, PermissionError):\n        print('Could not find file LINGUAS in {}'.format(src_sub))\n        return []\n\ndef run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> int:\n    listfile = os.path.join(src_sub, 'POTFILES.in')\n    if not os.path.exists(listfile):\n        listfile = os.path.join(src_sub, 'POTFILES')\n        if not os.path.exists(listfile):\n            print('Could not find file POTFILES in %s' % src_sub)\n            return 1\n\n    child_env = os.environ.copy()\n    if datadirs:\n        child_env['GETTEXTDATADIRS'] = datadirs\n\n    ofile = os.path.join(src_sub, pkgname + '.pot')\n    return subprocess.call(['xgettext', '--package-name=' + pkgname, '-p', src_sub, '-f', listfile,\n                            '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args,\n                           env=child_env)\n\ndef gen_gmo(src_sub: str, bld_sub: str, langs: T.List[str]) -> int:\n    for l in langs:\n        subprocess.check_call(['msgfmt', os.path.join(src_sub, l + '.po'),\n                               '-o', os.path.join(bld_sub, l + '.gmo')])\n    return 0\n\ndef update_po(src_sub: str, pkgname: str, langs: T.List[str]) -> int:\n    potfile = os.path.join(src_sub, pkgname + '.pot')\n    for l in langs:\n        pofile = os.path.join(src_sub, l + '.po')\n        if os.path.exists(pofile):\n            subprocess.check_call(['msgmerge', '-q', '-o', pofile, pofile, potfile])\n        else:\n            subprocess.check_call(['msginit', '--input', potfile, '--output-file', pofile, '--locale', l, '--no-translator'])\n    return 0\n\ndef do_install(src_sub: str, bld_sub: str, dest: str, pkgname: str, langs: T.List[str]) -> int:\n    for l in langs:\n        srcfile = os.path.join(bld_sub, l + '.gmo')\n        outfile = os.path.join(dest, l, 'LC_MESSAGES',\n                               pkgname + '.mo')\n        tempfile = outfile + '.tmp'\n        os.makedirs(os.path.dirname(outfile), exist_ok=True)\n        shutil.copy2(srcfile, tempfile)\n        os.replace(tempfile, outfile)\n        print('Installing %s to %s' % (srcfile, outfile))\n    return 0\n\ndef run(args: T.List[str]) -> int:\n    options = parser.parse_args(args)\n    subcmd = options.command\n    langs = options.langs.split('@@') if options.langs else None\n    extra_args = options.extra_args.split('@@') if options.extra_args else []\n    subdir = os.environ.get('MESON_SUBDIR', '')\n    if options.subdir:\n        subdir = options.subdir\n    src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], subdir)\n    bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], subdir)\n\n    if not langs:\n        langs = read_linguas(src_sub)\n\n    if subcmd == 'pot':\n        return run_potgen(src_sub, options.pkgname, options.datadirs, extra_args)\n    elif subcmd == 'gen_gmo':\n        return gen_gmo(src_sub, bld_sub, langs)\n    elif subcmd == 'update_po':\n        if run_potgen(src_sub, options.pkgname, options.datadirs, extra_args) != 0:\n            return 1\n        return update_po(src_sub, options.pkgname, langs)\n    elif subcmd == 'install':\n        destdir = os.environ.get('DESTDIR', '')\n        dest = destdir_join(destdir, os.path.join(os.environ['MESON_INSTALL_PREFIX'],\n                                                  options.localedir))\n        if gen_gmo(src_sub, bld_sub, langs) != 0:\n            return 1\n        do_install(src_sub, bld_sub, dest, options.pkgname, langs)\n    else:\n        print('Unknown subcommand.')\n        return 1\n    return 0\n", "path": "mesonbuild/scripts/gettext.py"}], "after_files": [{"content": "# Copyright 2016 The Meson development team\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport shutil\nimport argparse\nimport subprocess\nfrom . import destdir_join\nimport typing as T\n\nparser = argparse.ArgumentParser()\nparser.add_argument('command')\nparser.add_argument('--pkgname', default='')\nparser.add_argument('--datadirs', default='')\nparser.add_argument('--langs', default='')\nparser.add_argument('--localedir', default='')\nparser.add_argument('--subdir', default='')\nparser.add_argument('--extra-args', default='')\n\ndef read_linguas(src_sub: str) -> T.List[str]:\n    # Syntax of this file is documented here:\n    # https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html\n    linguas = os.path.join(src_sub, 'LINGUAS')\n    try:\n        langs = []\n        with open(linguas) as f:\n            for line in f:\n                line = line.strip()\n                if line and not line.startswith('#'):\n                    langs += line.split()\n        return langs\n    except (FileNotFoundError, PermissionError):\n        print('Could not find file LINGUAS in {}'.format(src_sub))\n        return []\n\ndef run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> int:\n    listfile = os.path.join(src_sub, 'POTFILES.in')\n    if not os.path.exists(listfile):\n        listfile = os.path.join(src_sub, 'POTFILES')\n        if not os.path.exists(listfile):\n            print('Could not find file POTFILES in %s' % src_sub)\n            return 1\n\n    child_env = os.environ.copy()\n    if datadirs:\n        child_env['GETTEXTDATADIRS'] = datadirs\n\n    ofile = os.path.join(src_sub, pkgname + '.pot')\n    return subprocess.call(['xgettext', '--package-name=' + pkgname, '-p', src_sub, '-f', listfile,\n                            '-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args,\n                           env=child_env)\n\ndef gen_gmo(src_sub: str, bld_sub: str, langs: T.List[str]) -> int:\n    for l in langs:\n        subprocess.check_call(['msgfmt', os.path.join(src_sub, l + '.po'),\n                               '-o', os.path.join(bld_sub, l + '.gmo')])\n    return 0\n\ndef update_po(src_sub: str, pkgname: str, langs: T.List[str]) -> int:\n    potfile = os.path.join(src_sub, pkgname + '.pot')\n    for l in langs:\n        pofile = os.path.join(src_sub, l + '.po')\n        if os.path.exists(pofile):\n            subprocess.check_call(['msgmerge', '-q', '-o', pofile, pofile, potfile])\n        else:\n            subprocess.check_call(['msginit', '--input', potfile, '--output-file', pofile, '--locale', l, '--no-translator'])\n    return 0\n\ndef do_install(src_sub: str, bld_sub: str, dest: str, pkgname: str, langs: T.List[str]) -> int:\n    for l in langs:\n        srcfile = os.path.join(bld_sub, l + '.gmo')\n        outfile = os.path.join(dest, l, 'LC_MESSAGES',\n                               pkgname + '.mo')\n        tempfile = outfile + '.tmp'\n        os.makedirs(os.path.dirname(outfile), exist_ok=True)\n        shutil.copy2(srcfile, tempfile)\n        os.replace(tempfile, outfile)\n        if not os.getenv('MESON_INSTALL_QUIET', False):\n            print('Installing %s to %s' % (srcfile, outfile))\n    return 0\n\ndef run(args: T.List[str]) -> int:\n    options = parser.parse_args(args)\n    subcmd = options.command\n    langs = options.langs.split('@@') if options.langs else None\n    extra_args = options.extra_args.split('@@') if options.extra_args else []\n    subdir = os.environ.get('MESON_SUBDIR', '')\n    if options.subdir:\n        subdir = options.subdir\n    src_sub = os.path.join(os.environ['MESON_SOURCE_ROOT'], subdir)\n    bld_sub = os.path.join(os.environ['MESON_BUILD_ROOT'], subdir)\n\n    if not langs:\n        langs = read_linguas(src_sub)\n\n    if subcmd == 'pot':\n        return run_potgen(src_sub, options.pkgname, options.datadirs, extra_args)\n    elif subcmd == 'gen_gmo':\n        return gen_gmo(src_sub, bld_sub, langs)\n    elif subcmd == 'update_po':\n        if run_potgen(src_sub, options.pkgname, options.datadirs, extra_args) != 0:\n            return 1\n        return update_po(src_sub, options.pkgname, langs)\n    elif subcmd == 'install':\n        destdir = os.environ.get('DESTDIR', '')\n        dest = destdir_join(destdir, os.path.join(os.environ['MESON_INSTALL_PREFIX'],\n                                                  options.localedir))\n        if gen_gmo(src_sub, bld_sub, langs) != 0:\n            return 1\n        do_install(src_sub, bld_sub, dest, options.pkgname, langs)\n    else:\n        print('Unknown subcommand.')\n        return 1\n    return 0\n", "path": "mesonbuild/scripts/gettext.py"}]}