Browse code

Compile Horizon message catalogs during stack.sh

Recently compiled message catalogs (mo files) were removed
in Horizon and django_openstack_auth repositories.
We need to compile message catalogs to make translations
available for Horizon users. It is useful for developers too.

Change-Id: I0831e8308205c116d8e3bb8b43be7f0dd6fa0c0a

Akihiro Motoki authored on 2014/10/15 17:26:59
Showing 3 changed files
... ...
@@ -27,3 +27,4 @@ bc
27 27
 libyaml-dev
28 28
 libffi-dev
29 29
 libssl-dev # for pyOpenSSL
30
+gettext  # used for compiling message catalogs
... ...
@@ -26,6 +26,7 @@ wget
26 26
 which
27 27
 bc
28 28
 libyaml-devel
29
+gettext  # used for compiling message catalogs
29 30
 
30 31
 # [1] : some of installed tools have unversioned dependencies on this,
31 32
 # but others have versioned (<=0.7).  So if a later version (0.7.1)
... ...
@@ -84,6 +84,14 @@ function cleanup_horizon {
84 84
 # configure_horizon() - Set config files, create data dirs, etc
85 85
 function configure_horizon {
86 86
     setup_develop $HORIZON_DIR
87
+
88
+    # Compile message catalogs.
89
+    # Horizon is installed as develop mode, so we can compile here.
90
+    # Message catalog compilation is handled by Django admin script,
91
+    # so compiling them after the installation avoids Django installation twice.
92
+    cd $HORIZON_DIR
93
+    ./run_tests.sh -N --compilemessages
94
+    cd -
87 95
 }
88 96
 
89 97
 # init_horizon() - Initialize databases, etc.
... ...
@@ -138,6 +146,13 @@ function init_horizon {
138 138
 # install_django_openstack_auth() - Collect source and prepare
139 139
 function install_django_openstack_auth {
140 140
     git_clone $HORIZONAUTH_REPO $HORIZONAUTH_DIR $HORIZONAUTH_BRANCH
141
+
142
+    # Compile message catalogs before installation
143
+    _prepare_message_catalog_compilation
144
+    cd $HORIZONAUTH_DIR
145
+    python setup.py compile_catalog
146
+    cd -
147
+
141 148
     setup_install $HORIZONAUTH_DIR
142 149
 }
143 150
 
... ...
@@ -160,6 +175,13 @@ function stop_horizon {
160 160
     stop_apache_server
161 161
 }
162 162
 
163
+# NOTE: It can be moved to common functions, but it is only used by compilation
164
+# of django_openstack_auth catalogs at the moment.
165
+function _prepare_message_catalog_compilation {
166
+    local babel_package=$(grep ^Babel $REQUIREMENTS_DIR/global-requirements.txt)
167
+    pip_install "$babel_package"
168
+}
169
+
163 170
 
164 171
 # Restore xtrace
165 172
 $XTRACE