Skip to content

Commit 4d393ff

Browse files
committed
Add a new setting to enable/disable the fallback (opther) option.
1 parent 6f86632 commit 4d393ff

File tree

6 files changed

+50
-6
lines changed

6 files changed

+50
-6
lines changed

classes/plugininfo.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,14 @@ public static function get_plugin_configuration_for_context(context $context, ar
153153
}
154154
// Only multilang2 filter allows a general catch all fallback.
155155
if ($mlangfilter) {
156-
$config['languages'][] = [
157-
'iso' => 'other',
158-
'label' => get_string('multilang2:other', 'tiny_multilang2') . ' (other)',
159-
];
156+
// Also check that the fallback option is enabled (which is true by default).
157+
$showfallbackother = (bool)get_config('tiny_multilang2', 'showfallbackother');
158+
if ($showfallbackother) {
159+
$config['languages'][] = [
160+
'iso' => 'other',
161+
'label' => get_string('multilang2:other', 'tiny_multilang2') . ' (other)',
162+
];
163+
}
160164
}
161165
}
162166

lang/en/tiny_multilang2.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
$string['requiremultilang2_desc'] = 'If enabled, the language drop down menu is visible only when the Multi-Language Content (v2) filter is enabled.';
6262
$string['showalllangs'] = 'Show all languages';
6363
$string['showalllangs_desc'] = 'If enabled, the language drop down menu will contain all the languages Moodle supports. If not, only the installed and enabled languages will be shown.';
64+
$string['showfallbackother'] = 'Show fallback (other) option';
65+
$string['showfallbackother_desc'] = 'With the Multi-Language filter, a fallback (other) option exisits, when defining a language block that should match any installed language and there is no part for the current used language defined.';
6466

6567
// Deprecated since Moodle 4.5.
6668
$string['helplinktext'] = 'Multi-Language Content (v2)';

settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
get_string('requiremultilang2', 'tiny_multilang2'), get_string('requiremultilang2_desc', 'tiny_multilang2'), 1));
3636
$settings->add(new admin_setting_configcheckbox('tiny_multilang2/showalllangs',
3737
get_string('showalllangs', 'tiny_multilang2'), get_string('showalllangs_desc', 'tiny_multilang2'), 0));
38+
$settings->add(new admin_setting_configcheckbox('tiny_multilang2/showfallbackother',
39+
get_string('showfallbackother', 'tiny_multilang2'), get_string('showfallbackother_desc', 'tiny_multilang2'), 1));
3840
$settings->add(new admin_setting_configcheckbox('tiny_multilang2/highlight',
3941
get_string('highlight', 'tiny_multilang2'), get_string('highlight_desc', 'tiny_multilang2'), 1));
4042
$settings->add(new admin_setting_configtextarea(
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@editor @editor_tiny @tiny @tiny_multilang2 @javascript
2+
Feature: Test the tiny editor multilang plugin with the fallback other feature enabled or disabled.
3+
4+
Background: I login as admin and add a text to the description with two paragraphs.
5+
Given the following config values are set as admin:
6+
| requiremultilang2 | 0 | tiny_multilang2 |
7+
| highlight | 1 | tiny_multilang2 |
8+
| showfallbackother | 1 | tiny_multilang2 |
9+
And the following "language packs" exist:
10+
| language |
11+
| de |
12+
And the "multilang" filter is "on"
13+
And the "multilang" filter applies to "content"
14+
And the "multilang2" filter is "on"
15+
And the "multilang2" filter applies to "content"
16+
And I log in as "admin"
17+
18+
Scenario: Toggle the showfallbackother setting.
19+
Given I log in as "admin"
20+
And I open my profile in edit mode
21+
And I wait until the page is ready
22+
And I click on the "Format > Language" submenu item for the "Description" TinyMCE editor
23+
Then I should see "English (en)"
24+
And I should see "Deutsch (de)"
25+
And I should see "Remove all lang tags"
26+
And I should see "Fallback (other)"
27+
When I navigate to "Plugins > Text editors > Multi-Language Content (v2)" in site administration
28+
And I set the field "s_tiny_multilang2_showfallbackother" to "0"
29+
And I click on "Save changes" "button"
30+
And I open my profile in edit mode
31+
And I wait until the page is ready
32+
And I click on the "Format > Language" submenu item for the "Description" TinyMCE editor
33+
Then I should see "English (en)"
34+
And I should see "Deutsch (de)"
35+
And I should see "Remove all lang tags"
36+
And I should not see "Fallback (other)"

tests/behat/tiny_langfallback.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Feature: Tiny editor multilang plugin for default behaviour with no multilangfil
55
Background: I login as admin and add a text to the description with two paragraphs.
66
Given the following config values are set as admin:
77
| requiremultilang2 | 0 | tiny_multilang2 |
8-
| highlight | 1 | tiny_multilang2 |
8+
| highlight | 1 | tiny_multilang2 |
99
And the following "language packs" exist:
1010
| language |
1111
| de |

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
$plugin->component = 'tiny_multilang2';
3131
$plugin->release = '1.6';
32-
$plugin->version = 2025050700;
32+
$plugin->version = 2025050701;
3333
$plugin->requires = 2022112800;
3434
$plugin->maturity = MATURITY_STABLE;
3535
$plugin->supported = [401, 500];

0 commit comments

Comments
 (0)