aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Traits/HelpHelperTrait.php8
-rw-r--r--tests/unit/Module/HelpTest.php9
2 files changed, 15 insertions, 2 deletions
diff --git a/Zotlabs/Lib/Traits/HelpHelperTrait.php b/Zotlabs/Lib/Traits/HelpHelperTrait.php
index b7711bbd5..9e4fefa4b 100644
--- a/Zotlabs/Lib/Traits/HelpHelperTrait.php
+++ b/Zotlabs/Lib/Traits/HelpHelperTrait.php
@@ -53,10 +53,10 @@ trait HelpHelperTrait {
// Use local variable until we can use trait constants.
$valid_file_ext = ['md', 'bb', 'html'];
- $base_path = "doc/{$lang}/${base_path}";
+ $base_path_with_lang = "doc/{$lang}/${base_path}";
foreach ($valid_file_ext as $ext) {
- $path = "{$base_path}.{$ext}";
+ $path = "{$base_path_with_lang}.{$ext}";
if (file_exists($path)) {
$this->file_name = $path;
$this->file_type = $ext;
@@ -64,5 +64,9 @@ trait HelpHelperTrait {
break;
}
}
+
+ if (empty($this->file_name) && $lang !== 'en') {
+ $this->find_help_file($base_path, 'en');
+ }
}
}
diff --git a/tests/unit/Module/HelpTest.php b/tests/unit/Module/HelpTest.php
index 64e4a2663..2e5494f7c 100644
--- a/tests/unit/Module/HelpTest.php
+++ b/tests/unit/Module/HelpTest.php
@@ -103,6 +103,15 @@ class HelpTest extends \Zotlabs\Tests\Unit\Module\TestCase {
$this->get('help/first');
}
+ public function test_fall_back_to_english_if_localized_topic_dont_exist(): void {
+ \App::$language = 'nb';
+
+ $stubs = $this->prepare_stubs('bb');
+ $this->get('help/about/help_topic');
+
+ $this->assertPageContains('Hubzilla Documentation: About');
+ }
+
public function test_includes(): void {
// Stub `file_get_contents` to plant our own content.
$fgc_stub = $this->getFunctionMock('Zotlabs\Module', 'file_get_contents');