Skip to content

Commit

Permalink
Fix parent - child language files generation.
Browse files Browse the repository at this point in the history
While the standard multi-language plugin only creates the language
file for the child, we need to create both the child and the parent
files. The difference is due to the functions that both plugin use to
get the parent languages.

This was the reason why the unit test that tried to use the parent -
child relationship data failed unless we also specified the child
language in the block lang list: we simply didn't get the parent
language back when asking the string manager.

Now that we have fixed the language files generation, the unit test
works as it should.
  • Loading branch information
iarenaza committed Oct 28, 2024
1 parent f163f84 commit 2d68c00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/actual_test_cases.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ function multilang2_actual_test_cases(): array {
'¡Hola!
This text is common for all languages because it is outside of all lang blocks.
',
'{mlang other}Hello!{mlang}{mlang es,es_mx}¡Hola!{mlang}
'{mlang other}Hello!{mlang}{mlang es}¡Hola!{mlang}
This text is common for all languages because it is outside of all lang blocks.
{mlang other}Bye!{mlang}{mlang it}Ciao!{mlang}',
'es_mx', ['es_mx' => 'es'],
'es_mx',
['es_mx' => 'es'],
],
[
'
Expand Down
5 changes: 5 additions & 0 deletions tests/filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ protected function setup_parent_language(string $child, string $parent): void {
check_dir_exists($langfolder);
$langconfig = "<?php\n\$string['parentlanguage'] = '$parent';";
file_put_contents($langfolder . '/langconfig.php', $langconfig);

$langfolder = $CFG->dataroot . '/lang/' . $parent;
check_dir_exists($langfolder);
$langconfig = "<?php\n\$string['parentlanguage'] = '';";
file_put_contents($langfolder . '/langconfig.php', $langconfig);
}

/**
Expand Down

0 comments on commit 2d68c00

Please sign in to comment.