File: generate-mos

package info (click to toggle)
ymuse 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: xml: 295; sh: 27; makefile: 22
file content (27 lines) | stat: -rwxr-xr-x 751 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash
# Generates .mo compiled language files

set -e

app_id="ymuse"
root_dir="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")"

# Remove compiled .mo files, if any
mo_dir="$root_dir/resources/i18n/generated"
rm -rf "$mo_dir"

# Iterate through all source .po files
find "$root_dir" -type f -name '*.po' |
    while read file; do
        # Language is the filename without the extension
        lang="$(basename "$file")"
        lang="${lang%.*}"

        # Create the target dir if needed
        target_dir="$mo_dir/$lang/LC_MESSAGES"
        mkdir -p "$target_dir"

        # Compile the .po into a .mo
        echo "Compiling $file" into "$target_dir/$app_id.mo"
        msgfmt "$file" -o "$target_dir/$app_id.mo"
    done