Add importing of translations from Transifex [MAILPOET-849]
This commit is contained in:
9
.tx/config
Normal file
9
.tx/config
Normal 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
|
@@ -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]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
|
1
build.sh
1
build.sh
@@ -3,6 +3,7 @@
|
||||
# Translations (npm install & composer install need to be run before)
|
||||
echo '[BUILD] Generating translations'
|
||||
./do makepot
|
||||
./do packtranslations
|
||||
|
||||
plugin_name='mailpoet'
|
||||
|
||||
|
19
tasks/pack_translations.sh
Normal file
19
tasks/pack_translations.sh
Normal 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"
|
Reference in New Issue
Block a user