Last active
February 26, 2022 08:28
-
-
Save manuelcanga/dae7fe922c1b70d6205736239cb6ee7a to your computer and use it in GitHub Desktop.
Searching and creating gettext entries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_ROOT=$1 | |
if [ $# == 2 ] | |
then | |
echo "error: app path?" | |
fi | |
echo "1.Creating smarty.php in $APP_ROOT" | |
echo "<?php" >$APP_ROOT/smarty.php | |
grep -hoie "{t}.*{/t}" $APP_ROOT/* -R|sed "s/{t}/echo _\(\'/g"|sed "s/{\/t}/\'\);/g"|grep -hoiE "_\('.+'\)" >>$APP_ROOT/smarty.php | |
echo -e "\n?>" >>$APP_ROOT/smarty.php | |
echo "2.Creating javascript.php in $APP_ROOT" | |
echo "<?php" >$APP_ROOT/_javascript.php | |
find . -iname "*.js" -exec grep -hoiE "_\('.+'\)" {} >>$APP_ROOT/_javascript.php \; | |
echo -e "\n?>" >>$APP_ROOT/_javascript.php | |
sed -e "s/^_/echo\ _/g" $APP_ROOT/_javascript.php > $APP_ROOT/javascript.php | |
rm _javascript.php | |
echo "3.Creating messages.po from app \( $APP_ROOT \) " | |
$(rm messages.po 2>/dev/null) | |
touch messages.po | |
find $APP_ROOT -iname "*.php" -exec xgettext {} -j --from-code=iso-8859-1 \; | |
rm $APP_ROOT/smarty.php | |
rm $APP_ROOT/javascript.php | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment