Skip to content

Commit f989b90

Browse files
Get rid of the LINGUAS file
1 parent e0d870a commit f989b90

File tree

5 files changed

+19
-38
lines changed

5 files changed

+19
-38
lines changed

po/LINGUAS

Lines changed: 0 additions & 3 deletions
This file was deleted.

po/README.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
To add a new translation:
22

3-
- Add the language code to the `LINGUAS` file
4-
- Add the .po file to the `po_files` list in `meson.build`
5-
- Build the `update_all_po` target to create the new .po file
3+
- Add the name of the new .po file to the `po_files` list in `meson.build` (no need to create the file).
4+
- Build the `update_all_po` target to create the new .po file.
5+
- Edit the new .po file.

po/meson.build

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
fs = import('fs')
2-
31
xgettext = find_program('xgettext')
42
msgmerge = find_program('msgmerge')
3+
msginit = find_program('msginit')
54
msgfmt = find_program('msgfmt')
65

76
po_files = [
@@ -127,6 +126,11 @@ input_files = [
127126
scanner_strings,
128127
]
129128

129+
languages = []
130+
foreach po_file : po_files
131+
languages += [po_file.split('.')[0]]
132+
endforeach
133+
130134
update_pot = custom_target(
131135
'update_pot',
132136
output: gettext_package + '.pot',
@@ -141,13 +145,14 @@ update_pot = custom_target(
141145

142146
update_all_po = custom_target(
143147
'update_all_po',
144-
input: [update_pot, 'LINGUAS'],
148+
input: update_pot,
145149
output: po_files,
146150
command: [
147151
'meson_helpers/update_all_po.sh',
148-
'@INPUT@',
149-
'@OUTDIR@',
150152
'@CURRENT_SOURCE_DIR@',
153+
'@OUTDIR@',
154+
'@INPUT@',
155+
languages,
151156
],
152157
)
153158

po/meson_helpers/update_all_po.sh

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
11
#!/bin/bash
22

3-
pot_file=$1
4-
linguas_file=$2
5-
build_dir=$3
6-
src_dir=$4
3+
src_dir=$1
4+
build_dir=$2
5+
pot_file=$3
76

8-
# Reads the LINGUAS file and outputs each word, one per line, from non-comment lines.
9-
# Ignores empty lines and lines starting with # (and optional leading whitespace).
10-
get_linguas() {
11-
if [[ ! -f "${linguas_file}" ]]; then
12-
echo "Error: LINGUAS file not found." >&2
13-
return 1
14-
fi
15-
16-
while IFS= read -r line || [[ -n "$line" ]]; do
17-
# Skip empty lines and lines that start with # (possibly preceded by whitespace)
18-
if [[ -n "$line" && ! "$line" =~ ^\s*# ]]; then
19-
# Process the line: split into words and print each word on a new line.
20-
# $line is intentionally unquoted here to allow word splitting by IFS.
21-
for word in $line; do
22-
echo "$word"
23-
done
24-
fi
25-
done < "${linguas_file}"
26-
}
7+
shift 3
278

28-
langs=$(get_linguas)
29-
for lang in $langs; do
9+
for lang in "$@"; do
3010
if [[ -f "${build_dir}/${lang}.po" ]]; then
3111
rm "${build_dir}/${lang}.po"
3212
fi

po/meson_helpers/update_pot.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ src_dir=$1
44
output=$2
55

66
shift 2
7-
inputs=$@
87

9-
xgettext ${inputs} \
8+
xgettext "$@" \
109
--from-code=UTF-8 \
1110
--add-comments \
1211
--keyword=_ \

0 commit comments

Comments
 (0)