forked from polychromatic/polychromatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-locales.sh
executable file
·46 lines (41 loc) · 1.23 KB
/
build-locales.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Step 2: After locales have been created and translated, generate compiled
# locales for the application to use, such as
# /usr/share/locale/en_GB/LC_MESSAGES/polychromatic.mo
#
# Requires "msgfmt" to be installed (usually provided in the 'gettext' package)
#
# To update locales from the source code, run ./create-locales.sh instead.
#
# Parameters:
# $1 Optional. Path to save compiled locales
#
cd "$(dirname "$0")"/../locale
output_path="$1"
# Check all the required tools are present
if [ -z "$(which msgfmt)" ]; then
echo "Command for 'msgfmt' not found. Locales will not be compiled."
echo "Try installing a 'gettext' package for your distribution."
exit 1
fi
# A parameter to the script can optionally override where the place the output.
if [ -z "$output_path" ]; then
output_path="$(pwd)"
fi
if [ ! -d "$output_path" ]; then
mkdir "$output_path"
fi
# Compile locales
echo -n "Compiling locales using 'msgfmt'..."
for file in $(ls *.po)
do
locale=${file%.*}
locale_path="$output_path/$locale/LC_MESSAGES/"
if [ -d "$locale_path" ]; then
rm -r "$locale_path"
fi
mkdir -p "$locale_path"
msgfmt $locale.po -o "$locale_path/polychromatic.mo"
done
echo " done!"