Skip to content

Commit

Permalink
MAJOR: added 4th step in language translation that is to merge all po…
Browse files Browse the repository at this point in the history
… files and put them in storage then compile new mo files, seems to fix most translation issues
  • Loading branch information
antonraharja committed Jul 11, 2015
1 parent c4eead1 commit e5d8948
Show file tree
Hide file tree
Showing 70 changed files with 39,177 additions and 181 deletions.
20 changes: 10 additions & 10 deletions contrib/tools/language/1-update-pot-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ fi
CWD=$(pwd)

##Common strings
cd $PLAYSMS
touch plugin/language/messages.pot
touch plugin/language/index.html
xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o plugin/language/messages.pot init.php
xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o plugin/language/messages.pot index.php
find lib/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o plugin/language/messages.pot {} \;
find inc/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o plugin/language/messages.pot {} \;
find plugin/themes/common/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o plugin/language/messages.pot {} \;
cd $PLAYSMS/plugin
touch language/messages.pot
touch language/index.html
xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot ../init.php
xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot ../index.php
find ../lib/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;
find ../inc/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;
find themes/common/ -iname "*.php" -exec xgettext -L PHP --omit-header --no-location --sort-output --from-code=utf-8 -j -o language/messages.pot {} \;
cd $CWD

##Themes,plugins and tools strings
cd $PLAYSMS
find . -type d -name "language" | grep -v "plugin/language" | sed -e "s/\/[^\/]*$//" > /tmp/.lang_folders
cd $PLAYSMS/plugin
find . -type d -name "language" | grep -v "language" | sed -e "s/\/[^\/]*$//" > /tmp/.lang_folders
for i in `cat /tmp/.lang_folders` ; do mkdir -p "$i/language" ; done
for i in `cat /tmp/.lang_folders` ; do rm -f "$i/language/messages.pot" ; done
for i in `cat /tmp/.lang_folders` ; do touch "$i/language/messages.pot" ; done
Expand Down
4 changes: 2 additions & 2 deletions contrib/tools/language/2-merge-existing-po-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi

CWD=$(pwd)

cd $PLAYSMS
cd $PLAYSMS/plugin
find . -type d -name "language" | sed -e "s/\/[^\/]*$//" > /tmp/.lang_folders
for i in `cat /tmp/.lang_folders` ; do
for j in `ls -1 "$i/language/" | grep '_'` ; do
Expand All @@ -20,7 +20,7 @@ for i in `cat /tmp/.lang_folders` ; do
msgmerge "$i/language/$j/LC_MESSAGES/messages.po" "$i/language/messages.pot" > "$i/language/$j/LC_MESSAGES/messages.po.tmp"
mv "$i/language/$j/LC_MESSAGES/messages.po.tmp" "$i/language/$j/LC_MESSAGES/messages.po"
echo -n "$i/language/$j/LC_MESSAGES/messages.po"
msgattrib --no-obsolete "$i/language/$j/LC_MESSAGES/messages.po" -o "$i/language/$j/LC_MESSAGES/messages.po"
msgattrib --no-obsolete --previous "$i/language/$j/LC_MESSAGES/messages.po" -o "$i/language/$j/LC_MESSAGES/messages.po"
done
done
echo
Expand Down
2 changes: 1 addition & 1 deletion contrib/tools/language/3-regenerating-mo-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi

CWD=$(pwd)

cd $PLAYSMS
cd $PLAYSMS/plugin
find . -type d -name "language" | sed -e "s/\/[^\/]*$//" > /tmp/.lang_folders
for i in `cat /tmp/.lang_folders` ; do
for j in `ls -1 "$i/language/" | grep '_'` ; do
Expand Down
41 changes: 41 additions & 0 deletions contrib/tools/language/4-compile-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

PLAYSMS=$1

if [ -z "$PLAYSMS" ]; then
echo "Usage: $0 <playSMS installation path>"
exit 1
fi

CWD=$(pwd)

cd $PLAYSMS/plugin

for j in `ls -1 "$PLAYSMS/plugin/language/" | grep '_'` ; do
mkdir -p "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES"
touch "$PLAYSMS/storage/plugin/index.html"
touch "$PLAYSMS/storage/plugin/language/index.html"
touch "$PLAYSMS/storage/plugin/language/$j/index.html"
touch "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/index.html"
touch "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/messages.po"
rm "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/.po_files" >/dev/null 2>&1
touch "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/.po_files"
done

find . -type d -name "language" | sed -e "s/\/[^\/]*$//" > /tmp/.lang_folders
for i in `cat /tmp/.lang_folders` ; do
for j in `ls -1 "$i/language/" | grep '_'` ; do
echo "$i/language/$j/LC_MESSAGES/messages.po " >> "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/.po_files"
done
done

for j in `ls -1 "$PLAYSMS/plugin/language/" | grep '_'` ; do
PO_FILES=`cat "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/.po_files"`
msgcat --force-po --use-first --lang $j -t UTF-8 -s -o "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/messages.po" $PO_FILES
msgfmt -vv "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/messages.po" -o "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/messages.mo"
rm -f "$PLAYSMS/storage/plugin/language/$j/LC_MESSAGES/.po_files" >/dev/null 2>&1
done

cd $CWD

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ fi
./1-update-pot-files.sh $PLAYSMS
./2-merge-existing-po-files.sh $PLAYSMS
./3-regenerating-mo-files.sh $PLAYSMS
./4-compile-all.sh $PLAYSMS

exit 0
17 changes: 0 additions & 17 deletions web/inc/app/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@

$continue = TRUE;

if (function_exists('bindtextdomain')) {
bindtextdomain('messages', _APPS_PATH_PLUG_.'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

// load plugin
if ($continue && _INC_) {
$p = explode('_', _INC_, 2);
Expand All @@ -36,21 +30,10 @@
$file_name = ( _ROUTE_ ? _ROUTE_.'.php' : $plugin_name.'.php' );
$plugin_file = $plugin_dir.'/'.$file_name;
if (file_exists($plugin_file)) {
if (function_exists('bindtextdomain')) {
bindtextdomain('messages', $plugin_dir.'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}
include_once $plugin_file;
}
}

if (function_exists('bindtextdomain')) {
bindtextdomain('messages', _APPS_PATH_THEMES_.'/'.core_themes_get().'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

$content = ob_get_clean();

_p(themes_apply($content));
10 changes: 0 additions & 10 deletions web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
// _APP_=call to access subroutine in a plugin
// can be used to replace callback.php in clickatell or dlr.php and geturl.php in kannel
if (_CAT_ && _PLUGIN_) {
if (function_exists('bindtextdomain')) {
bindtextdomain('messages', $core_config['apps_path']['plug'] . '/' . _CAT_ . '/' . _PLUGIN_ . '/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}
core_hook(_PLUGIN_, 'call', array(
$_REQUEST
));
Expand All @@ -65,11 +60,6 @@
if (_INC_) {
$fn = $core_config['apps_path']['themes'] . '/' . core_themes_get() . '/page_' . _INC_ . '.php';
if (file_exists($fn)) {
if (function_exists('bindtextdomain')) {
bindtextdomain('messages', $core_config['apps_path']['themes'] . '/' . core_themes_get() . '/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}
include $fn;
} else {
$fn = $core_config['apps_path']['themes'] . '/common/page_' . _INC_ . '.php';
Expand Down
12 changes: 6 additions & 6 deletions web/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@
die(_('FATAL ERROR') . ' : ' . _('Fail to load language') . ' ' . core_lang_get());
}

if (function_exists('bindtextdomain')) {
bindtextdomain('messages', _APPS_PATH_STORAGE_ . '/plugin/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

if (auth_isvalid()) {

// set user lang
Expand All @@ -319,12 +325,6 @@
core_setuserlang();
}

if (function_exists('bindtextdomain')) {
bindtextdomain('messages', _APPS_PATH_PLUG_ . '/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

// fixme anton - debug
//print_r($icon_config); die();
//print_r($menu_config); die();
Expand Down
6 changes: 0 additions & 6 deletions web/lib/fn_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1231,12 +1231,6 @@ function core_last_post_empty() {
$c_fn1 = $dir . '/' . $pl . '/config.php';
$c_fn2 = $dir . '/' . $pl . '/fn.php';
if (file_exists($c_fn1) && file_exists($c_fn2)) {
if (function_exists('bindtextdomain') && file_exists($dir . '/' . $pl . '/language')) {
bindtextdomain('messages', $pl_dir . '/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

// config.php
include $c_fn1;

Expand Down
21 changes: 0 additions & 21 deletions web/lib/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@
$pl_dir = $dir.$pc.'/'.$pl;
$c_fn1 = $pl_dir.'/config.php';
if (file_exists($c_fn1)) {
if (function_exists('bindtextdomain') && file_exists($pl_dir.'/language')) {
bindtextdomain('messages', $pl_dir.'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}
include $c_fn1;
}
}
Expand All @@ -93,11 +88,6 @@
$pl_dir = $dir.$pc.'/'.$pl;
$c_fn1 = $pl_dir.'/fn.php';
if (file_exists($c_fn1)) {
if (function_exists('bindtextdomain') && file_exists($pl_dir.'/language')) {
bindtextdomain('messages', $pl_dir.'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}
include $c_fn1;
}
}
Expand All @@ -110,11 +100,6 @@
$pl_dir = $dir.$pc.'/'.$pl;
$c_fn1 = $pl_dir.'/fn.php';
if (file_exists($c_fn1)) {
if (function_exists('bindtextdomain') && file_exists($pl_dir.'/language/')) {
bindtextdomain('messages', $plugin_dir.'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}
include $c_fn1;
}

Expand Down Expand Up @@ -151,12 +136,6 @@
}
}

if (function_exists('bindtextdomain')) {
bindtextdomain('messages', $core_config['apps_path']['plug'].'/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

// fixme anton - debug
//print_r($icon_config); die();
//print_r($menu_config); die();
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions web/plugin/feature/mailsms/mailsms.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
'ACTION_URL' => _u('index.php?app=main&inc=feature_mailsms&op=mailsms_save'),
'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_,
'HINT_PASSWORD' => _hint(_('Fill the password field to change password')),
'SAVE' => _('Save'),
'Email to SMS address' => _('Email to SMS address'),
'Enable fetch new emails' => _('Enable fetch new emails'),
'Check email sender' => _('Check email sender'),
Expand Down
1 change: 1 addition & 0 deletions web/plugin/feature/mailsms/mailsms_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'ACTION_URL' => _u('index.php?app=main&inc=feature_mailsms&route=mailsms_user&op=mailsms_user_save'),
'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_,
'HINT_PASSWORD' => _hint(_('Fill the password field to change password')),
'SAVE' => _('Save'),
'Email to SMS address' => _('Email to SMS address'),
'PIN for email to SMS' => _mandatory(_('PIN for email to SMS'))
),
Expand Down
2 changes: 1 addition & 1 deletion web/plugin/feature/mailsms/templates/mailsms.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ <h2>{{ FORM_TITLE }}</h2>
</tr>
</tbody>
</table>
<p><input type=submit class=button value='{{ Save }}'></p>
<p><input type=submit class=button value='{{ SAVE }}'></p>
</form>
2 changes: 1 addition & 1 deletion web/plugin/feature/mailsms/templates/mailsms_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ <h2>{{ FORM_TITLE }}</h2>
</tbody>
</table>
<p>
<input type=submit class=button value='{{ Save }}'>
<input type=submit class=button value='{{ SAVE }}'>
</p>
</form>
6 changes: 0 additions & 6 deletions web/plugin/themes/common/config.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?php
defined('_SECURE_') or die('Forbidden');

if (function_exists('bindtextdomain')) {
bindtextdomain('messages', $core_config['apps_path']['plug'] . '/language/');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
}

// common action icons

$icon_config = array(
Expand Down
Loading

0 comments on commit e5d8948

Please sign in to comment.