aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-07-24 11:46:18 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-07-24 11:46:18 +0200
commit61f9ad8274d662a056aff05407771fb450a2ab35 (patch)
tree6f65e2155680993e370dab51c512d7c9da925be4
parent7067a0adc2e37168401e761c29e78392229ec168 (diff)
downloadvolse-hubzilla-61f9ad8274d662a056aff05407771fb450a2ab35.tar.gz
volse-hubzilla-61f9ad8274d662a056aff05407771fb450a2ab35.tar.bz2
volse-hubzilla-61f9ad8274d662a056aff05407771fb450a2ab35.zip
Add a notice to help pages when defaulting to english.
-rw-r--r--Zotlabs/Lib/Traits/HelpHelperTrait.php26
-rw-r--r--tests/unit/Module/HelpTest.php1
-rw-r--r--view/tpl/help.tpl5
3 files changed, 24 insertions, 8 deletions
diff --git a/Zotlabs/Lib/Traits/HelpHelperTrait.php b/Zotlabs/Lib/Traits/HelpHelperTrait.php
index 2a54e2db2..0ce586d08 100644
--- a/Zotlabs/Lib/Traits/HelpHelperTrait.php
+++ b/Zotlabs/Lib/Traits/HelpHelperTrait.php
@@ -20,6 +20,7 @@ trait HelpHelperTrait {
private array $lang = [
'language' => 'en', //! Detected language, 2-letter ISO 639-1 code ("en")
'from_url' => false, //! true if language from URL overrides browser default
+ 'missing' => false, //! true if topic not found in detected language
];
/**
@@ -36,17 +37,15 @@ trait HelpHelperTrait {
$languages = $language_repository->getList();
if(array_key_exists(argv(1), $languages)) {
- $lang = argv(1);
- $from_url = true;
+ $this->lang['language'] = argv(1);
+ $this->lang['from_url'] = true;
} else {
- $lang = \App::$language;
- if(! isset($lang))
- $lang = 'en';
+ if(isset(\App::$language)) {
+ $this->lang['language'] = \App::$language;
+ }
- $from_url = false;
+ $this->lang['from_url'] = false;
}
-
- $this->lang = array('language' => $lang, 'from_url' => $from_url);
}
/**
@@ -74,7 +73,18 @@ trait HelpHelperTrait {
}
if (empty($this->file_name) && $lang !== 'en') {
+ $this->lang['missing'] = true;
$this->find_help_file($base_path, 'en');
}
}
+
+ public function missing_translation(): bool {
+ return !!$this->lang['missing'];
+ }
+
+ public function missing_translation_message(): string {
+ return bbcode(
+ t("This page is not yet available in your preferred language. See [observer.baseurl]/help/developer/developer_guide#Translations for information about how to help.")
+ );
+ }
}
diff --git a/tests/unit/Module/HelpTest.php b/tests/unit/Module/HelpTest.php
index 2e5494f7c..81d2e9287 100644
--- a/tests/unit/Module/HelpTest.php
+++ b/tests/unit/Module/HelpTest.php
@@ -110,6 +110,7 @@ class HelpTest extends \Zotlabs\Tests\Unit\Module\TestCase {
$this->get('help/about/help_topic');
$this->assertPageContains('Hubzilla Documentation: About');
+ $this->assertPageContains('This page is not yet available in your preferred language');
}
public function test_includes(): void {
diff --git a/view/tpl/help.tpl b/view/tpl/help.tpl
index 1cc66d258..0dc9bc686 100644
--- a/view/tpl/help.tpl
+++ b/view/tpl/help.tpl
@@ -2,6 +2,11 @@
<div class="clearfix section-title-wrapper">
<h2>{{$module->get_page_title()}}</h2>
</div>
+ {{if $module->missing_translation()}}
+ <div class="notice section-content-info-wrapper">
+ {{$module->missing_translation_message()}}
+ </div>
+ {{/if}}
<div class="section-content-wrapper" id="doco-content">
<h3 id="doco-top-toc-heading">
<span class="fakelink" onclick="docoTocToggle(); return false;">