Skip to content

Instantly share code, notes, and snippets.

@jleyva
Created January 28, 2014 15:29
Show Gist options
  • Save jleyva/8669654 to your computer and use it in GitHub Desktop.
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
#!/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