fixed translations in opensearch.xml
This commit is contained in:
parent
5a4be6dad6
commit
90d3964ca2
12 changed files with 39 additions and 5 deletions
3
lang.go
3
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...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue