Add importing of translations from Transifex [MAILPOET-849]

This commit is contained in:
Alexey Stoletniy
2017-03-13 17:43:56 +03:00
parent 8db7af48cd
commit 5321a136e7
4 changed files with 35 additions and 0 deletions

9
.tx/config Normal file
View File

@@ -0,0 +1,9 @@
[main]
host = https://www.transifex.com
[mp3.mailpoet]
source_file = lang/mailpoet.pot
file_filter = lang/mailpoet-<lang>.po
source_lang = en_US
type = PO
minimum_perc = 100

View File

@@ -104,6 +104,12 @@ class RoboFile extends \Robo\Tasks {
); );
} }
function packtranslations() {
// Define WP_TRANSIFEX_API_TOKEN env. variable
$this->loadEnv();
return $this->_exec('./tasks/pack_translations.sh');
}
function testUnit($opts=['file' => null, 'xml' => false]) { function testUnit($opts=['file' => null, 'xml' => false]) {
$this->loadEnv(); $this->loadEnv();
$this->_exec('vendor/bin/codecept build'); $this->_exec('vendor/bin/codecept build');

View File

@@ -3,6 +3,7 @@
# Translations (npm install & composer install need to be run before) # Translations (npm install & composer install need to be run before)
echo '[BUILD] Generating translations' echo '[BUILD] Generating translations'
./do makepot ./do makepot
./do packtranslations
plugin_name='mailpoet' plugin_name='mailpoet'

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Write .transifexrc file if not exists
if [ ! -f ~/.transifexrc ]; then
echo "[https://www.transifex.com]" > ~/.transifexrc
echo "hostname = https://www.transifex.com" >> ~/.transifexrc
echo "username = api" >> ~/.transifexrc
echo "password = $WP_TRANSIFEX_API_TOKEN" >> ~/.transifexrc
echo "token =" >> ~/.transifexrc
fi
echo "Getting translations from Transifex..."
tx pull -a
echo "Generating MO files..."
for file in `find ./lang/ -name "*.po"` ; do
msgfmt -o ${file/.po/.mo} $file
done
echo "Done"