3 # Copyright (C) 2020 Tim-Philipp Müller <tim centricular net>
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Library General Public License for more details.
15 # You should have received a copy of the GNU Library General Public
16 # License along with this library; if not, write to the
17 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 # Boston, MA 02110-1301, USA.
26 if __name__ == "__main__":
27 dist_root = os.environ['MESON_DIST_ROOT']
28 build_root = os.environ['MESON_BUILD_ROOT']
29 source_root = os.environ['MESON_SOURCE_ROOT']
30 project_version = sys.argv[1]
31 pwd = os.environ['PWD']
32 tmpdir = tempfile.gettempdir()
34 module = os.path.basename(os.path.normpath(source_root))
37 print('Generating pot file ...')
38 subprocess.run(['ninja', '-C', build_root, module + '-1.0-pot'], check=True)
40 pot_src = os.path.join(source_root, 'po', module + '-1.0.pot')
42 # Dist pot file in tarball, and fix up version in POT file to match
43 # Translation Project requirements as part of the copying.
44 with open(pot_src, 'r') as f:
47 pot_file = pot_file.replace(f'Project-Id-Version: {module}-1.0',
48 f'Project-Id-Version: {module}-{project_version}', 1)
50 print('Copying pot file into dist staging directory ...')
51 dist_pot_with_suffix = os.path.join(dist_root, 'po', f'{module}-1.0.pot')
52 with open(dist_pot_with_suffix, 'w') as f:
55 # And another copy without the 1.0 suffix
56 dist_pot_without_suffix = os.path.join(dist_root, 'po', f'{module}.pot')
57 with open(dist_pot_without_suffix, 'w') as f: