Merge pull request #3723 from crazyserver/MOBILE-4362

Mobile 4362
main
Noel De Martin 2023-07-04 16:54:00 +02:00 committed by GitHub
commit 26147e85ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 141 additions and 139 deletions

View File

@ -61,8 +61,6 @@ jobs:
apt:
packages:
- libsecret-1-dev
- php5-cli
- php5-common
- name: "Build iOS"
language: node_js
if: env(BUILD_IOS) = 1 AND (env(DEPLOY) = 1 OR (env(DEPLOY) = 2 AND tag IS NOT blank))

View File

@ -1,13 +1,13 @@
#!/bin/bash
source "scripts/functions.sh"
if [ -z $GIT_TOKEN ]; then
if [ -z "$GIT_TOKEN" ]; then
print_error "Env vars not correctly defined"
exit 1
fi
print_title "Run scripts"
git clone --depth 1 --single-branch --branch ionic5 https://$GIT_TOKEN@github.com/moodlemobile/apps-scripts.git ../scripts
git clone --depth 1 --single-branch --branch ionic5 https://"$GIT_TOKEN"@github.com/moodlemobile/apps-scripts.git ../scripts
cp ../scripts/*.sh scripts/
if [ ! -f scripts/platform.sh ]; then

View File

@ -9,7 +9,7 @@
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
cd $DIR
cd "$DIR"
source "functions.sh"
source "lang_functions.sh"
@ -27,7 +27,7 @@ if [ ! -f 'langindex.json' ]; then
fi
findbetter=$1
parse_file $findbetter
parse_file "$findbetter"
echo

View File

@ -8,15 +8,15 @@ SERVER_URL='https://download.moodle.org/'
# Downloads a file and if it's a zip file, unzip it.
function download_file {
local url=$1
local filename=$(basename ${url})
local filename=$(basename "${url}")
pushd $LANGPACKS_PATH > /dev/null
pushd "$LANGPACKS_PATH" > /dev/null
curl -s $url --output $filename > /dev/null
curl -s "$url" --output "$filename" > /dev/null
size=$(du -k "$filename" | cut -f 1)
if [ ! -n $filename ] || [ $size -le 1 ]; then
if [ ! -n "$filename" ] || [ "$size" -le 1 ]; then
echo "Wrong or corrupt file $filename"
rm $filename
rm "$filename"
popd > /dev/null
return
@ -25,21 +25,21 @@ function download_file {
if [[ $filename == *.zip ]]; then
local lang="${filename%.*}"
# Delete previous downloaded folder
rm -R $lang > /dev/null 2>&1> /dev/null
rm -R "$lang" > /dev/null 2>&1> /dev/null
# Unzip
unzip -o -u $lang.zip > /dev/null
unzip -o -u "$lang".zip > /dev/null
# Delete the zip
rm $filename
rm "$filename"
fi
popd > /dev/null
}
function get_english {
if [ ! -d $LANGPACKS_PATH ]; then
mkdir $LANGPACKS_PATH
if [ ! -d "$LANGPACKS_PATH" ]; then
mkdir "$LANGPACKS_PATH"
fi
get_app_version
@ -63,7 +63,7 @@ function save_key {
function remove_key {
local key=$1
cat langindex.json | jq 'del(."'$key'")' > langindex_new.json
cat langindex.json | jq 'del(."'"$key"'")' > langindex_new.json
mv langindex_new.json langindex.json
print_ok "Deleted unused key $key"
}
@ -73,14 +73,14 @@ function exists_in_file {
local file=$1
local id=$2
file=`echo $file | sed s/^mod_workshop_assessment/workshopform/1`
file=`echo $file | sed s/^mod_assign_/assign/1`
file=`echo $file | sed s/^mod_//1`
file=$(echo "$file" | sed s/^mod_workshop_assessment/workshopform/1)
file=$(echo "$file" | sed s/^mod_assign_/assign/1)
file=$(echo "$file" | sed s/^mod_//1)
completeFile="$LANGPACKS_PATH/en/$file.php"
if [ -f "$completeFile" ]; then
foundInFile=`grep "string\[\'$id\'\]" $completeFile`
if [ ! -z "$foundInFile" ]; then
foundInFile=$(grep "string\['${id}'\]" "${completeFile}")
if [ -n "$foundInFile" ]; then
coincidence=1
found=$file
return
@ -93,7 +93,7 @@ function exists_in_file {
#Checks if a key exists on the original local_moodlemobileapp.php
function exists_in_mobile {
local file='local_moodlemobileapp'
exists_in_file $file $key
exists_in_file $file "$key"
}
function do_match {
@ -101,14 +101,14 @@ function do_match {
match=${match/\}\}/\}}
filematch=""
coincidence=`grep "$match" $LANGPACKS_PATH/en/*.php | wc -l`
if [ $coincidence -eq 1 ]; then
filematch=`grep "$match" $LANGPACKS_PATH/en/*.php | cut -d'/' -f5 | cut -d'.' -f1`
exists_in_file $filematch $plainid
elif [ $coincidence -gt 0 ] && [ "$#" -gt 1 ]; then
coincidence=$(grep "$match" "$LANGPACKS_PATH"/en/*.php | wc -l)
if [ "$coincidence" -eq 1 ]; then
filematch=$(grep "$match" "$LANGPACKS_PATH"/en/*.php | cut -d'/' -f5 | cut -d'.' -f1)
exists_in_file "$filematch" "$plainid"
elif [ "$coincidence" -gt 0 ] && [ "$#" -gt 1 ]; then
print_message "$2"
tput setaf 6
grep "$match" $LANGPACKS_PATH/en/*.php
grep "$match" "$LANGPACKS_PATH"/en/*.php
else
coincidence=0
fi
@ -117,48 +117,48 @@ function do_match {
#Find if the id or the value can be found on files to help providing a solution.
function find_matches {
do_match "string\[\'$plainid\'\] = \'$value\'" "Found EXACT match for $key in the following paths"
if [ $coincidence -gt 0 ]; then
if [ "$coincidence" -gt 0 ]; then
case=1
save_key $key "TBD"
save_key "$key" "TBD"
return
fi
do_match " = \'$value\'" "Found some string VALUES for $key in the following paths"
if [ $coincidence -gt 0 ]; then
if [ "$coincidence" -gt 0 ]; then
case=2
save_key $key "TBD"
save_key "$key" "TBD"
return
fi
do_match "string\[\'$plainid\'\]" "Found some string KEYS for $key in the following paths, value $value"
if [ $coincidence -gt 0 ]; then
if [ "$coincidence" -gt 0 ]; then
case=3
save_key $key "TBD"
save_key "$key" "TBD"
return
fi
print_message "No match found for $key add it to local_moodlemobileapp"
save_key $key "local_moodlemobileapp"
save_key "$key" "local_moodlemobileapp"
}
function find_single_matches {
do_match "string\[\'$plainid\'\] = \'$value\'"
if [ ! -z $filematch ] && [ $found != 0 ]; then
if [ -n "$filematch" ] && [ "$found" != 0 ]; then
case=1
return
fi
do_match " = \'$value\'"
if [ ! -z $filematch ] && [ $filematch != 'local_moodlemobileapp' ]; then
if [ -n "$filematch" ] && [ "$filematch" != 'local_moodlemobileapp' ]; then
case=2
print_message "Found some string VALUES for $key in the following paths $filematch"
tput setaf 6
grep "$match" $LANGPACKS_PATH/en/*.php
grep "$match" "$LANGPACKS_PATH"/en/*.php
return
fi
do_match "string\[\'$plainid\'\]"
if [ ! -z $filematch ] && [ $found != 0 ]; then
if [ -n "$filematch" ] && [ "$found" != 0 ]; then
case=3
return
fi
@ -170,47 +170,47 @@ function guess_file {
local key=$1
local value=$2
local type=`echo $key | cut -d'.' -f1`
local component=`echo $key | cut -d'.' -f2`
local plainid=`echo $key | cut -d'.' -f3-`
local type=$(echo "$key" | cut -d'.' -f1)
local component=$(echo "$key" | cut -d'.' -f2)
local plainid=$(echo "$key" | cut -d'.' -f3-)
if [ -z "$plainid" ]; then
plainid=$component
component='moodle'
fi
exists_in_file $component $plainid
exists_in_file "$component" "$plainid"
if [ $found == 0 ]; then
tempid=`echo $plainid | sed s/^mod_//1`
if [ $component == 'moodle' ] && [ "$tempid" != "$plainid" ]; then
exists_in_file $plainid pluginname
if [ "$found" == 0 ]; then
tempid=$(echo "$plainid" | sed s/^mod_//1)
if [ "$component" == 'moodle' ] && [ "$tempid" != "$plainid" ]; then
exists_in_file "$plainid" pluginname
if [ $found != 0 ]; then
if [ "$found" != 0 ]; then
found=$found/pluginname
fi
fi
fi
# Not found in file, try in local_moodlemobileapp
if [ $found == 0 ]; then
if [ "$found" == 0 ]; then
exists_in_mobile
fi
# Still not found, if only found in one file, use it.
if [ $found == 0 ]; then
if [ "$found" == 0 ]; then
find_single_matches
fi
# Last fallback.
if [ $found == 0 ]; then
exists_in_file 'moodle' $plainid
if [ "$found" == 0 ]; then
exists_in_file 'moodle' "$plainid"
fi
if [ $found == 0 ]; then
if [ "$found" == 0 ]; then
find_matches
else
save_key $key $found
save_key "$key" "$found"
fi
}
@ -219,27 +219,29 @@ function current_translation_exists {
local current=$2
local file=$3
plainid=`echo $key | cut -d'.' -f3-`
plainid=$(echo "$key" | cut -d'.' -f3-)
if [ -z "$plainid" ]; then
plainid=`echo $key | cut -d'.' -f2`
plainid=$(echo "$key" | cut -d'.' -f2)
fi
local currentFile=`echo $current | cut -d'/' -f1`
local currentStr=`echo $current | cut -d'/' -f2-`
if [ $currentFile == $current ]; then
local currentFile=$(echo "$current" | cut -d'/' -f1)
local currentStr=$(echo "$current" | cut -d'/' -f2-)
if [ "$currentFile" == "$current" ]; then
currentStr=$plainid
fi
exists_in_file $currentFile $currentStr
if [ $found == 0 ]; then
exists_in_file "$currentFile" "$currentStr"
if [ "$found" == 0 ]; then
# Translation not found.
exec="jq -r .\"$key\" $file"
value=`$exec`
value=$($exec)
found=$($exec)
print_error "Translation of '$currentStr' not found in '$currentFile'"
guess_file $key "$value"
guess_file "$key" "$value"
fi
}
@ -249,24 +251,24 @@ function find_better_file {
local value=$2
local current=$3
local type=`echo $key | cut -d'.' -f1`
local component=`echo $key | cut -d'.' -f2`
local plainid=`echo $key | cut -d'.' -f3-`
local type=$(echo "$key" | cut -d'.' -f1)
local component=$(echo "$key" | cut -d'.' -f2)
local plainid=$(echo "$key" | cut -d'.' -f3-)
if [ -z "$plainid" ]; then
plainid=$component
component='moodle'
fi
local currentFile=`echo $current | cut -d'/' -f1`
local currentStr=`echo $current | cut -d'/' -f2-`
if [ $currentFile == $current ]; then
local currentFile=$(echo "$current" | cut -d'/' -f1)
local currentStr=$(echo "$current" | cut -d'/' -f2-)
if [ "$currentFile" == "$current" ]; then
currentStr=$plainid
fi
exists_in_file $component $plainid
if [ $found != 0 ] && [ $currentStr == $plainid ]; then
if [ $found != $currentFile ]; then
exists_in_file "$component" "$plainid"
if [ "$found" != 0 ] && [ "$currentStr" == "$plainid" ]; then
if [ "$found" != "$currentFile" ]; then
print_ok "Key '$key' found in component, no need to replace old '$current'"
fi
@ -274,27 +276,27 @@ function find_better_file {
fi
# Still not found, if only found in one file, use it.
if [ $found == 0 ]; then
if [ "$found" == 0 ]; then
find_single_matches
fi
if [ $found != 0 ] && [ $found != $currentFile ] && [ $case -lt 3 ]; then
if [ "$found" != 0 ] && [ "$found" != "$currentFile" ] && [ "$case" -lt 3 ]; then
print_message "Indexed string '$key' found in '$found' better than '$current'"
return
fi
if [ $currentFile == 'local_moodlemobileapp' ]; then
if [ "$currentFile" == 'local_moodlemobileapp' ]; then
exists_in_mobile
else
exists_in_file $currentFile $currentStr
exists_in_file "$currentFile" "$currentStr"
fi
if [ $found == 0 ]; then
if [ "$found" == 0 ]; then
print_error "Indexed string '$key' not found on current place '$current'"
if [ $currentFile != 'local_moodlemobileapp' ]; then
if [ "$currentFile" != 'local_moodlemobileapp' ]; then
print_error "Execute this on AMOS
CPY [$currentStr,$currentFile],[$key,local_moodlemobileapp]"
save_key $key "local_moodlemobileapp"
save_key "$key" "local_moodlemobileapp"
fi
fi
}
@ -304,39 +306,41 @@ function parse_file {
file="$LANG_PATH/en.json"
findbetter=$1
keys=`jq -r 'keys[]' $file`
keys=$(jq -r 'keys[]' "$file")
for key in $keys; do
echo -n '.'
# Check if already parsed.
exec="jq -r .\"$key\" langindex.json"
found=`$exec`
found=$($exec)
if [ -z "$found" ] || [ "$found" == 'null' ]; then
exec="jq -r .\"$key\" $1"
value=`$exec`
guess_file $key "$value"
exec="jq -r .\"$key\" $file"
value=$($exec)
guess_file "$key" "$value"
else
if [ "$found" == 'donottranslate' ]; then
# Do nothing since is not translatable.
continue
elif [ ! -z "$findbetter" ]; then
exec="jq -r .\"$key\" $1"
value=`$exec`
elif [ -n "$findbetter" ]; then
exec="jq -r .\"$key\" $file"
value=$($exec)
find_better_file "$key" "$value" "$found"
elif [ "$found" != 'local_moodlemobileapp' ]; then
current_translation_exists "$key" "$found" "$1"
current_translation_exists "$key" "$found" "$file"
fi
fi
done
# Do some cleanup
langkeys=`jq -r 'keys[]' langindex.json`
langkeys=$(jq -r 'keys[]' langindex.json)
findkeys="${keys[@]}"
for key in $langkeys; do
# Check if already used.
array_contains "$key" "$findkeys"
if [ -z "$found" ] || [ "$found" == 'null' ]; then
remove_key $key
remove_key "$key"
fi
done
}

View File

@ -58,13 +58,13 @@ function print_title {
}
function telegram_notify {
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
if [ ! -z "$TELEGRAM_APIKEY" ] && [ ! -z "$TELEGRAM_CHATID" ] ; then
set_branch_and_repo
MESSAGE="$1%0ABranch: *$REFNAME* on $REPO%0ACommit: $COMMIT%0AJob: $JOB ($RUN_NUMBER) [Complete log here]($JOB_URL)"
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
curl -s -X POST "$URL" -d chat_id="$TELEGRAM_CHATID" -d text="$MESSAGE"
fi
}
@ -78,12 +78,12 @@ function notify_on_error_exit {
function set_branch_and_repo {
if [ ! -z $REPO ]; then
if [ ! -z "$REPO" ]; then
# Already filled.
return;
fi
if [ -z $TRAVIS_OS_NAME ]; then
if [ -z "$TRAVIS_OS_NAME" ]; then
#Run on github
if [ "$RUNNER_OS" == 'macOS' ]; then
export OS_NAME='osx'
@ -118,12 +118,12 @@ function set_branch_and_repo {
export CI_TYPE='travis'
fi
if [ -z $REFNAME ]; then
if [ -z "$REFNAME" ]; then
print_error "Empty branch/tag, cancelling..."
exit 0
fi
if [ -z $REPO ]; then
if [ -z "$REPO" ]; then
print_error "Empty repo, cancelling..."
exit 0
fi

View File

@ -14,8 +14,8 @@ function get_app_version {
return
fi
APP_VERSION=`jq -r '.versionname' ../moodle.config.json| cut -d. -f1-2`
if [ ! -z $APP_VERSION ]; then
APP_VERSION=$(jq -r '.versionname' ../moodle.config.json| cut -d. -f1-2)
if [ ! -z "$APP_VERSION" ]; then
export LANGVERSION=$APP_VERSION
echo "Using app version $LANGVERSION"
return

View File

@ -21,37 +21,37 @@ function progressbar {
function copy_lang {
lang=$1
index_keys=`jq -r 'to_entries[] | "\"\(.key)\","' langindex.json`
index_keys=`echo $index_keys | sed 's/,*$//'`
index_keys=$(jq -r 'to_entries[] | "\"\(.key)\","' langindex.json)
index_keys=$(echo "$index_keys" | sed 's/,*$//')
hyphenlang=${lang/_/-}
langfilepath=$LANG_PATH/$hyphenlang.json
cp $LANGPACKS_PATH/$lang.json $langfilepath
cp "$LANGPACKS_PATH"/"$lang".json "$langfilepath"
# Merge SUFFIX file if exists.
if [ ! -z "$SUFFIX" ] && [ -f "$LANGPACKS_PATH/${lang}_${SUFFIX}.json" ]; then
if [ -n "$SUFFIX" ] && [ -f "$LANGPACKS_PATH/${lang}_${SUFFIX}.json" ]; then
suffixfilepath="$LANGPACKS_PATH/${lang}_${SUFFIX}.json"
jq --indent 4 -s --sort-keys ".[0] + .[1]" $langfilepath $suffixfilepath > /tmp/moodle-langtmp.json
mv /tmp/moodle-langtmp.json $langfilepath
jq --indent 4 -s --sort-keys ".[0] + .[1]" "$langfilepath" "$suffixfilepath" > /tmp/moodle-langtmp.json
mv /tmp/moodle-langtmp.json "$langfilepath"
fi
# Remove strings non exiting on langindex.
query="with_entries(select([.key] | inside([$index_keys])))"
jq --indent 2 -r "$query" $langfilepath > /tmp/moodle-langtmp.json
mv /tmp/moodle-langtmp.json $langfilepath
jq --indent 2 -r "$query" "$langfilepath" > /tmp/moodle-langtmp.json
mv /tmp/moodle-langtmp.json "$langfilepath"
name=`jq -r .\"$lang\".name $LANGPACKS_PATH/languages.json`
local=`jq -r .\"$lang\".local $LANGPACKS_PATH/languages.json`
translated=`jq -r '. | length' $langfilepath`
percentage=`echo "($translated * 100) /$LANGINDEX_STRINGS" | bc`
progressbar $percentage
name=$(jq -r .\""$lang"\".name "$LANGPACKS_PATH"/languages.json)
local=$(jq -r .\""$lang"\".local "$LANGPACKS_PATH"/languages.json)
translated=$(jq -r '. | length' "$langfilepath")
percentage=$(echo "($translated * 100) /$LANGINDEX_STRINGS" | bc)
progressbar "$percentage"
echo -e "Generated $hyphenlang\t $translated of $LANGINDEX_STRINGS\t $bar ($local local)"
# Add or update language name to config.
newlang="{\"$hyphenlang\": \"$name\"}"
languages=`jq -s --sort-keys ".[0].languages + $newlang" ../moodle.config.json`
languages=$(jq -s --sort-keys ".[0].languages + $newlang" ../moodle.config.json)
jq --indent 4 -s ".[0].languages = $languages | .[0]" ../moodle.config.json > /tmp/moodle-langtmp.json
mv /tmp/moodle-langtmp.json ../moodle.config.json
}
@ -59,28 +59,28 @@ function copy_lang {
function detect_lang {
lang=$1
name=`jq -r .\"$lang\".name $LANGPACKS_PATH/languages.json`
name=$(jq -r .\""$lang"\".name "$LANGPACKS_PATH"/languages.json)
if [ -z "$name" ] || [ "$name" == 'null' ]; then
continue
return
fi
hyphenlang=${lang/_/-}
if [ -f $LANG_PATH/$hyphenlang.json ]; then
if [ -f "$LANG_PATH"/"$hyphenlang".json ]; then
# Already exists
continue
return
fi
local=`jq -r .\"$lang\".local $LANGPACKS_PATH/languages.json`
translated=`jq -r .\"$lang\".translated $LANGPACKS_PATH/languages.json`
percentage=`echo "($translated * 100) /$TOTAL_STRINGS" | bc`
progressbar $percentage
local=$(jq -r .\""$lang"\".local "$LANGPACKS_PATH"/languages.json)
translated=$(jq -r .\""$lang"\".translated "$LANGPACKS_PATH"/languages.json)
percentage=$(echo "($translated * 100) /$TOTAL_STRINGS" | bc)
progressbar "$percentage"
echo -e "Checking $lang\t $translated of $TOTAL_STRINGS \t $bar ($local local)";
if [[ ( $percentage -gt 75 && $local -gt 50 ) || ( $percentage -gt 50 && $local -gt 75 ) ]] ; then
name=`jq -r .\"$lang\".name $LANGPACKS_PATH/languages.json`
name=$(jq -r .\""$lang"\".name "$LANGPACKS_PATH"/languages.json)
echo "*** NEW LANGUAGE DETECTED $lang - $name ***"
copy_lang $lang
copy_lang "$lang"
fi
}
@ -88,8 +88,8 @@ function load_langpacks {
get_app_version
print_title 'Getting local mobile langs'
if [ -d $LANGPACKS_PATH ]; then
pushd $LANGPACKS_PATH
if [ -d "$LANGPACKS_PATH" ]; then
pushd "$LANGPACKS_PATH"
git checkout "langpack_$LANGVERSION"
git pull
@ -101,16 +101,16 @@ function load_langpacks {
popd
else
git clone --depth 1 --single-branch --branch "langpack_$LANGVERSION" https://github.com/moodlehq/moodle-local_moodlemobileapp.git $LANGPACKS_PATH
git clone --depth 1 --single-branch --branch "langpack_$LANGVERSION" https://github.com/moodlehq/moodle-local_moodlemobileapp.git "$LANGPACKS_PATH"
if [ $? -ne 0 ]; then
echo "Cannot clone language repository"
exit 1
fi
fi
local_strings=`jq -r '.languages.local' $LANGPACKS_PATH/languages.json`
TOTAL_STRINGS=`jq -r '.languages.total' $LANGPACKS_PATH/languages.json`
LANGINDEX_STRINGS=`jq -r '. | length' langindex.json`
local_strings=$(jq -r '.languages.local' "$LANGPACKS_PATH"/languages.json)
TOTAL_STRINGS=$(jq -r '.languages.total' "$LANGPACKS_PATH"/languages.json)
LANGINDEX_STRINGS=$(jq -r '. | length' langindex.json)
print_message "Total strings to translate $TOTAL_STRINGS ($local_strings local)";
}
@ -119,29 +119,29 @@ function load_langpacks {
function get_languages {
print_title 'Copying existing languages'
# Existing languages, copy and clean the files.
langs=`jq -r '.languages | keys[]' ../moodle.config.json`
langs=$(jq -r '.languages | keys[]' ../moodle.config.json)
for lang in $langs; do
lang=${lang//-/_}
copy_lang $lang
copy_lang "$lang"
done
}
# Entry function to detect new languages.
function detect_languages {
# Do not detect new langs when suffix is set.
if [ ! -z $SUFFIX ]; then
if [ -n "$SUFFIX" ]; then
return
fi
print_title "Detect new languages"
langs=`jq -r 'keys[]' $LANGPACKS_PATH/languages.json`
langs=$(jq -r 'keys[]' "$LANGPACKS_PATH"/languages.json)
for lang in $langs; do
if [[ $lang = *_wp ]]; then
# Skip Workplace.
continue
fi
detect_lang $lang
detect_lang "$lang"
done
}
@ -156,10 +156,10 @@ function generate_local_module_file {
module_translations=''
keys=`jq -r 'map_values(select(contains("local_moodlemobileapp"))) | keys[]' langindex.json`
keys=$(jq -r 'map_values(select(contains("local_moodlemobileapp"))) | keys[]' langindex.json)
for key in $keys; do
# Check if already parsed.
translation=`jq -r .\"$key\" $LANG_PATH/en.json`
translation=$(jq -r .\""$key"\" "$LANG_PATH"/en.json)
if [ -z "$translation" ]; then
echo "Key $key not translated!"
continue
@ -173,13 +173,13 @@ function generate_local_module_file {
return
fi
echo -e $module_translations > /tmp/translations.php
echo -e "$module_translations" > /tmp/translations.php
filepath="../../moodle-$APPMODULENAME/lang/en/$APPMODULENAME.php";
BEGIN_GEN=$(cat $filepath | grep -n '\/\* AUTO START \*\/' | sed 's/\(.*\):.*/\1/g')
END_GEN=$(cat $filepath | grep -n '\/\* AUTO END \*\/' | sed 's/\(.*\):.*/\1/g')
cat <(head -n $BEGIN_GEN $filepath) /tmp/translations.php <(tail -n +$END_GEN $filepath) > /tmp/translations_temp.php
cat <(head -n "$BEGIN_GEN" $filepath) /tmp/translations.php <(tail -n +"$END_GEN" $filepath) > /tmp/translations_temp.php
mv /tmp/translations_temp.php $filepath
cp langindex.json ../../moodle-$APPMODULENAME

View File

@ -10,7 +10,7 @@
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
cd $DIR
cd "$DIR"
source "functions.sh"
source "lang_functions.sh"