Do not auto discover i18n files.

Revert to the plain old 'i18n_resources_list.txt' file.

Auto discovering of i18n file has a main flaw (and a small bug):
- The main flaw is that rerun the configure will not detect new
  translation files. It means that if we use cache in our CI,
  new translation will not be included.
- The bug is that on Windows, meson fails with a error about a non existent
  `` (empty) file name. I suppose it is because python replace
  `\n` by `\r\n` on Windows, and the the `.strip().split('\n')` keeps empty
  lines.

The small bug could be fixed, but the main flaw make the whole better if
we use a script to generate the listing.

This commit is somehow a half revert of 2eff5b55a6
This commit is contained in:
Matthieu Gautier 2022-05-16 12:00:00 +02:00
parent 5fb919e73e
commit 6e93bad565
2 changed files with 13 additions and 18 deletions

View File

@ -0,0 +1,2 @@
i18n/en.json
i18n/hy.json

View File

@ -24,24 +24,17 @@ lib_resources = custom_target('resources',
depends: preprocessed_resources
)
i18n_resource_listing_script = '''import glob
import os
import sys
qqq = sys.argv[1]
d = os.path.dirname(qqq)
r = glob.glob(d + "/*.json")
r.remove(qqq)
for f in r: print(f)
'''
i18n_resource_listing_cmd = [
find_program('python3'),
# This could be replaced with
# ```
# fs = import('fs')
# i18n_resource_files = fs.read('i18n_resources_list.txt').strip().split('\n')
# ```
# once we move to meson >= 0.57.0
i18n_resource_files = run_command(find_program('python3'),
'-c',
i18n_resource_listing_script,
files('i18n/qqq.json')
]
i18n_resource_files = run_command(i18n_resource_listing_cmd).stdout().strip().split('\n')
'import sys; f=open(sys.argv[1]); print(f.read())',
files('i18n_resources_list.txt')
).stdout().strip().split('\n')
i18n_resources = custom_target('i18n_resources',
input: i18n_resource_files,