-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Milestone
Description
The problem
Currently it is not possible to know if a translation key is available in a site's language.
Many themes rely on open contributions to maintain their localization. If a a new string needs to be added or and old one edited, maintainers need to either:
- Wait for localization contributor to translate it before releasing.
- Leave an untranslated string (printed as the default language's string) and hope for contributors to translate it later.
2. Will add this untranslated string to every project updating the theme.
Current workaround is rather clumsy (assumes default lang is en):
{{ $read_more := i18n "read_more_about_entry" }}
{{ if ne site.LanguageCode "en" }}
{{ if eq $read_more "read more about this entry" }}
{{ $read_more = i18n "read_more" }}
{{ end }}
{{ end }}
<a href="{{ .RelPermalink }}"> {{ $read_more }}</a>
Proposal
Introduce a new method on the lang object or the site.Lang object which tests the existence of a translation key and returns a boolean.
{{ $read_more := "read_more_about_entry" }}
{{ if not (site.Lang.HasTranslation "read_more_about_entry") }}
{{ $read_more = "read_more" }}
{{ end }}
<a href="{{ .RelPermalink }}"> {{ i18n $read_more }}</a>
McShelby