Created
January 28, 2014 15:29
-
-
Save jleyva/8669654 to your computer and use it in GitHub Desktop.
Fetch language packs from Moodle for the mobile app and convert it to .json files
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
#!/bin/bash | |
# GIT FILE PATH | |
GIT_PATH="/Users/juanleyvadelgado/Documents/MoodleMobile/moodle-langpacks/moodle-langpacks" | |
BRANCH="MOODLE_26_STABLE" | |
# Minimun number of strings translated the language pack should have | |
LINES_MIN=170 | |
cd $GIT_PATH | |
git checkout $BRANCH | |
git pull | |
packs=`find . -type f -name "local_moodlemobileapp.php"` | |
for f in $packs | |
do | |
lines=`cat $f | grep "string" | wc -l` | |
if [ $lines -gt $LINES_MIN ] | |
then | |
lang=`echo $f | sed "s/\.\///" | sed "s/\/.*//"` | |
file=$(cat $f | grep "\$string" | sed "s/\\\'/'/g" | sed "s/\$string\['/\"/g" | sed "s/'\] = '/\": \"/g" | sed "s/';/\",/g") | |
echo "{$file}" | sed "s/,}/}/g" > /tmp/$lang.json | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment