Skip to content

Commit

Permalink
Fix missing strings using fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Oct 4, 2023
1 parent be6ce0e commit db050a3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
23 changes: 20 additions & 3 deletions parser/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,35 @@ function build_lang(&$language) {
echo " Parent: $parent";
}

$langFile = false;
if (file_exists($lang.'.json')) {
// Load lang files just once.
$langFile = load_json($lang.'.json');
}

$translations = [];
// Add the translation to the array.
foreach ($LANGINDEX as $file => $keys) {
$lmsstring = get_translation_strings($langfoldername, $file);
if (empty($lmsstring)) {
if ($lang == 'en') {
echo "\n*DEBUG* File $file not found in $lang\n";
}
continue;
}

foreach ($keys as $appkey => $lmskey) {
if (!isset($lmsstring[$lmskey])) {
if ($appkey != 'core.parentlanguage') {
if ($langFile && isset($langFile[$appkey])) {
if ($lang == 'en') {
echo "\n*DEBUG* $appkey not found in $lang using fallback \n";
}
$translations[$appkey] = $langFile[$appkey];
} else if ($lang == 'en') {
echo "\n*DEBUG* $appkey not found in $lang!!! \n";
}
}
continue;
}

Expand All @@ -175,9 +194,7 @@ function build_lang(&$language) {
} else {
// @TODO: Remove that line when core.cannotconnect and core.login.invalidmoodleversion are completelly changed to use $a
if (($appkey == 'core.cannotconnect' || $appkey == 'core.login.invalidmoodleversion') && strpos($text, '2.4')) {
if (DEBUG) {
echo "****** Found 2.4 \n";
}
echo "\n*DEBUG* Found 2.4 in $lang $appkey \n";
$text = str_replace('2.4', '{{$a}}', $text);
}
$language->local++;
Expand Down
11 changes: 8 additions & 3 deletions parser/parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ function get_languages {
done < $LANGPACKSFOLDER/languages.md5
}

force=0

if [ ! -d $LANGPACKSFOLDER ]; then
mkdir $LANGPACKSFOLDER
fi

if [ ! -z $GIT_TOKEN ] && [ ! -z $GITHUB_REPOSITORY ]; then
# Set up Github Actions bot user
# See https://github.community/t/github-actions-bot-email-address/17204/6
Expand Down Expand Up @@ -101,15 +107,14 @@ if [ ! -f 'langindex.json' ]; then

download_file "$LANGINDEX_URL"

cp $LANGPACKSFOLDER langindex.json
cp $LANGPACKSFOLDER/langindex.json langindex.json
fi

langindexupdate=`date -r langindex.json +%s`
currenttime=`date +%s`
ellapsedtime=$((currenttime - langindexupdate))
force=0
if [ $ellapsedtime -lt 3600 ]; then
echo 'Recently updated, force update all languages'
echo 'Index recently updated, force update all languages'
force=1
fi

Expand Down

0 comments on commit db050a3

Please sign in to comment.