[DRE-commits] [redmine] 01/19: Reimplement language handling

Antonio Terceiro terceiro at moszumanska.debian.org
Mon Feb 15 12:31:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch master
in repository redmine.

commit 2dfb311f7fe2943caef3d44f5bde98e0145feb49
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Mon Feb 15 08:03:15 2016 -0200

    Reimplement language handling
---
 debian/check-locales | 16 ++++++++++++++++
 debian/config        | 18 +++++++++++++++++-
 debian/rules         |  1 +
 debian/templates     |  4 ++--
 4 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/debian/check-locales b/debian/check-locales
new file mode 100755
index 0000000..514a381
--- /dev/null
+++ b/debian/check-locales
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+locales=''
+for l in $(ls config/locales/ | sed -e 's/\.yml//g' | sort | tr '[:upper:]_' '[:lower:]-'); do
+  if [ -z "$locales" ]; then
+    locales="$l"
+  else
+    locales="$locales, $l"
+  fi
+done
+
+if ! grep -q "Choices: $locales" debian/templates; then
+  echo "E: debian/templates does not match available locales in config/locales/"
+  echo "E: make sure debian/template has \`Choices: $locales\`"
+  exit 1
+fi
diff --git a/debian/config b/debian/config
index b20cc02..3ec21de 100644
--- a/debian/config
+++ b/debian/config
@@ -2,6 +2,8 @@
 
 set -e
 
+system_locale=$(echo ${LANG%.*} | tr '[:upper:]_' '[:lower:]-')
+
 . /usr/share/debconf/confmodule
 
 if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
@@ -30,7 +32,21 @@ if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
         dbc_dbname="redmine_${inst}"
       fi
 
-      # TODO handle language for initial db data
+      # choose language
+      lang_question="redmine/instances/${inst}/default-language"
+      lang_rc=0
+      db_get "$lang_question" || lang_rc=$?
+      if [ $lang_rc -eq 10 ]; then
+        # question not instantiated yet
+        db_register redmine/default-language "$lang_question"
+        db_metaget redmine/default-language Choices || true
+        for lang in $(echo "$RET" | sed -e 's/,\s*/\n/g'); do
+          if [ "$system_locale" = "$lang" ]; then
+            db_set "$lang_question" "$system_locale"
+          fi
+        done
+      fi
+      db_input medium "$lang_question" || true
 
       dbc_go redmine/instances/$inst "$@"
     done
diff --git a/debian/rules b/debian/rules
index 8e75357..720a2cd 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,6 +5,7 @@
 	dh $@
 
 override_dh_auto_configure:
+	./debian/check-locales
 	bundle --local --quiet
 	rm -f Gemfile.lock
 
diff --git a/debian/templates b/debian/templates
index a66a359..ed9cab8 100644
--- a/debian/templates
+++ b/debian/templates
@@ -17,8 +17,8 @@ _Description: Redmine instances to be configured or upgraded:
 
 Template: redmine/default-language
 Type: select
-Choices: ${availableLocales}
-Default: ${defaultLocale}
+Choices: ar, az, bg, bs, ca, cs, da, de, el, en, en-gb, es, es-pa, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-br, ro, ru, sk, sl, sq, sr, sr-yu, sv, th, tr, uk, vi, zh, zh-tw
+Default: en
 _Description: Default redmine language:
 
 Template: redmine/missing-redmine-package

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/redmine.git



More information about the Pkg-ruby-extras-commits mailing list