Convert lektor_service_name in a generic envvars_localized plugin
With a few tweaks, the lektor_service_name plugin can be converted into a in a generic envvars_localized
plugin offering an unified way to translate content that's configured via environment variables.
A envvars_localized('VARIABLE_NAME', this.alt)
could be used anywhere in the templates to get the localized value for a given variable, or the default.
This function would make the following lookups:
-
Try to resolve a service name via
LEKTOR_VARIABLE_NAME_${LANG_CODE}
environment variable. -
If the variable above is unset, the function fallback to the value of the
LEKTOR_VARIABLE
environment variable, or an empty string (''
).