mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Add Translations and AllTranslations to Node
This commit also consolidates URLs on Node vs Page, so now .Permalink should be interoperable. Note that this implementations should be fairly short-livded, waiting for #2297, but the API should be stable.
This commit is contained in:
@@ -35,7 +35,8 @@ func SetTranslateLang(lang string) error {
|
||||
translater.current = f
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Translation func for language %v not found", lang)
|
||||
jww.WARN.Printf("Translation func for language %v not found", lang)
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetI18nTfuncs(bndl *bundle.Bundle) {
|
||||
@@ -58,7 +59,7 @@ func SetI18nTfuncs(bndl *bundle.Bundle) {
|
||||
}
|
||||
|
||||
func I18nTranslate(id string, args ...interface{}) (string, error) {
|
||||
if translater == nil {
|
||||
if translater == nil || translater.current == nil {
|
||||
return "", fmt.Errorf("i18n not initialized, have you configured everything properly?")
|
||||
}
|
||||
return translater.current(id, args...), nil
|
||||
|
Reference in New Issue
Block a user