diff --git a/init.go b/init.go index 9a7f62a..52789b7 100644 --- a/init.go +++ b/init.go @@ -65,6 +65,7 @@ func main() { // Start automatic update checker, not used now //go checkForUpdates() + InitializeLanguage("en") // Initialize language before generating OpenSearch generateOpenSearchXML(config) go startNodeClient() diff --git a/lang.go b/lang.go index 7b3e71f..c128168 100644 --- a/lang.go +++ b/lang.go @@ -14,7 +14,7 @@ func InitializeLanguage(siteLanguage string) { translationsDir := "lang" localeDir := filepath.Join(translationsDir, siteLanguage, "LC_MESSAGES") if _, err := os.Stat(localeDir); os.IsNotExist(err) { - printWarn("Translation directory for language '%s' does not exist. Using default.", siteLanguage) + printWarn("Translation directory for language '%s' not found. Defaulting to English.", siteLanguage) siteLanguage = "en" // Use default language if not found localeDir = filepath.Join(translationsDir, siteLanguage, "LC_MESSAGES") } @@ -26,6 +26,7 @@ func InitializeLanguage(siteLanguage string) { // Translate wraps gotext.Get and returns a translated string based on the given key. func Translate(key string, params ...interface{}) string { if translations == nil { + printWarn("Translation failed for key '%s'. This may occur if Translate is called before initializing language settings or if the key is missing.", key) return key // Fallback if translations are not initialized } return translations.Get(key, params...) diff --git a/lang/en/LC_MESSAGES/default.po b/lang/en/LC_MESSAGES/default.po index ee954aa..d88816b 100644 --- a/lang/en/LC_MESSAGES/default.po +++ b/lang/en/LC_MESSAGES/default.po @@ -40,6 +40,9 @@ msgstr "Site Language" msgid "search_language" msgstr "Search Language" +msgid "any_language" +msgstr "Any Language" + msgid "no_results" msgstr "No results found for '%s'. Try different keywords." @@ -189,3 +192,12 @@ msgstr "You are within " msgid "meters_from_point" msgstr "meters from this point" + +msgid "opensearch_shortname" +msgstr "QGato Search" + +msgid "opensearch_description" +msgstr "QGato - A Privacy-Focused Search Engine" + +msgid "opensearch_tags" +msgstr "search, qgato, spitfire" \ No newline at end of file diff --git a/lang/pl/LC_MESSAGES/default.po b/lang/pl/LC_MESSAGES/default.po index 99436a1..cb74a15 100644 --- a/lang/pl/LC_MESSAGES/default.po +++ b/lang/pl/LC_MESSAGES/default.po @@ -40,6 +40,9 @@ msgstr "Język strony" msgid "search_language" msgstr "Język wyszukiwania" +msgid "any_language" +msgstr "Dowolny język" + msgid "no_results" msgstr "Nie znaleziono wyników dla '%s'. Spróbuj innych słów kluczowych." @@ -189,3 +192,12 @@ msgstr "Znajdujesz się w odległości " msgid "meters_from_point" msgstr "metrów od tego punktu" + +msgid "opensearch_shortname" +msgstr "Wyszukiwarka QGato" + +msgid "opensearch_description" +msgstr "QGato - Prywatna wyszukiwarka internetowa" + +msgid "opensearch_tags" +msgstr "wyszukiwarka, qgato, spitfire" \ No newline at end of file diff --git a/main.go b/main.go index 138f279..3933fa2 100755 --- a/main.go +++ b/main.go @@ -109,6 +109,13 @@ func handleSearch(w http.ResponseWriter, r *http.Request) { InitializeLanguage(settings.SiteLanguage) + // Translate the "Any Language" option after initialization + for i, option := range languageOptions { + if option.Code == "" { + languageOptions[i].Name = Translate("any_language") + } + } + if query == "" { data := struct { LanguageOptions []LanguageOption diff --git a/open-search.go b/open-search.go index 0cdb72a..fe22f58 100644 --- a/open-search.go +++ b/open-search.go @@ -21,13 +21,14 @@ type URL struct { } func generateOpenSearchXML(config Config) { - baseURL := addProtocol(config.Domain) + // Ensure that language is initialized in `main` before calling this function + baseURL := addProtocol(config.Domain) opensearch := OpenSearchDescription{ Xmlns: "http://a9.com/-/spec/opensearch/1.1/", - ShortName: "QGato", - Description: "QGato search engine", - Tags: "search, spitfire, qgato", + ShortName: Translate("opensearch_shortname"), + Description: Translate("opensearch_description"), + Tags: Translate("opensearch_tags"), URLs: []URL{ { Type: "text/html", diff --git a/static/images/black.webp b/static/images/black.webp index 44386b5..e31aeb2 100644 Binary files a/static/images/black.webp and b/static/images/black.webp differ diff --git a/static/images/dark.webp b/static/images/dark.webp index ec0a27c..8213ab1 100644 Binary files a/static/images/dark.webp and b/static/images/dark.webp differ diff --git a/static/images/latte.webp b/static/images/latte.webp index 146d583..ee2669c 100644 Binary files a/static/images/latte.webp and b/static/images/latte.webp differ diff --git a/static/images/light.webp b/static/images/light.webp index be65002..bd473c2 100644 Binary files a/static/images/light.webp and b/static/images/light.webp differ diff --git a/static/images/mocha.webp b/static/images/mocha.webp index 5940ac4..55a0ae8 100644 Binary files a/static/images/mocha.webp and b/static/images/mocha.webp differ diff --git a/static/images/night.webp b/static/images/night.webp index 3329268..6924edf 100644 Binary files a/static/images/night.webp and b/static/images/night.webp differ