Add ability for jump to be translated into other languages

This commit is contained in:
Dale Davies
2023-04-06 17:49:27 +01:00
parent 5414f2b644
commit 0c2c320c75
26 changed files with 267 additions and 37 deletions

View File

@@ -26,7 +26,7 @@ class SearchEngines {
/**
* Automatically load searchengines.json on instantiation.
*/
public function __construct(private Config $config, private Cache $cache) {
public function __construct(private Config $config, private Cache $cache, private Language $language) {
$this->config = $config;
$this->loadedsearchengines = [];
$this->searchfilelocation = $this->config->get('searchenginesfile');
@@ -87,4 +87,22 @@ class SearchEngines {
public function get_search_engines() {
return $this->loadedsearchengines;
}
/**
* Return all the strings to be used by JS on the frontend.
*
* @return array
*/
public function get_strings_for_js(): array {
$strings = [
'search' => [
'search' => $this->language->get('search.search'),
'sites' => $this->language->get('search.sites'),
]
];
foreach ($this->loadedsearchengines as $searchengine) {
$strings['search']['searchon'][$searchengine->name] = $this->language->get('search.searchon', ['searchprovider' => $searchengine->name]);
}
return $strings;
}
}