Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/locales/locales_generator.sh
blob: 5386c3e6b5b0d8f6b57b2ea36e78f585d54f26ff (plain)
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
47
48
49
#!/bin/bash

cd $(dirname "$0")/..

function update_lang() {
  file=$1

	echo "Updating: $file"
	path=$(dirname $file)
	msgmerge --quiet --no-location --width 512 --backup none --update $file locales/base.pot
	msgfmt -o $path/base.mo $file
}


function generate_all() {
  for file in $(find locales/ -name "base.po"); do
    update_lang "$file"
  done
}

function generate_single_lang() {
  lang_file="locales/$1/LC_MESSAGES/base.po"

  if [ ! -f "$lang_file" ]; then
    echo "Language files not found: $lang_file"
    exit 1
  fi

  update_lang "$lang_file"
}



if [ $# -eq 0 ]
  then
    echo "Usage: locales_generator.sh <language_abbr>"
    exit 1
fi

lang=$1

# Update the base file containing all translatable string
find . -type f -iname "*.py" | xargs xgettext --join-existing --no-location --omit-header -d base -o locales/base.pot

case "$lang" in
  "all") generate_all
  ;;
  *) generate_single_lang "$lang"
esac