getzola/zola · error
Translation key '{}' for language '{}' is missing
Error message
Translation key '{}' for language '{}' is missing What it means
`Config::get_translation` looks up a translation string for a language code and key defined under `[languages.<lang>.translations]` in config.toml. It errors when the language exists but the requested key is absent from its translations map (or when the language itself is missing, with a different message). This surfaces in templates via the `trans()` Tera function.
Source
Thrown at components/config/src/config/mod.rs:380
}
pub fn enable_serve_mode(&mut self) {
self.mode = Mode::Serve;
}
pub fn enable_check_mode(&mut self) {
self.mode = Mode::Check;
// Disable syntax highlighting since the results won't be used and it is slow
self.markdown.highlighting = None;
}
pub fn get_translation(&self, lang: &str, key: &str) -> Result<String> {
if let Some(options) = self.languages.get(lang) {
options
.translations
.get(key)
.ok_or_else(|| {
anyhow!("Translation key '{}' for language '{}' is missing", key, lang)
})
.cloned()
} else {
bail!("Language '{}' not found.", lang)
}
}
pub fn has_taxonomy(&self, name: &str, lang: &str) -> bool {
if let Some(lang_options) = self.languages.get(lang) {
lang_options.taxonomies.iter().any(|t| t.name == name)
} else {
false
}
}
pub fn serialize(&self, lang: &str) -> SerializedConfig<'_> {
let options = &self.languages[lang];
View on GitHub (pinned to 61d3082821)
Solutions
- Add the missing key under `[languages.<lang>.translations]` in config.toml (e.g. `languages.fr.translations.title = "Titre"`), or under `[translations]` for the default language
- Check the key spelling in the template's `trans(key=...)` call matches config.toml exactly
- Verify the language code passed to trans/get_translation matches a `[languages.<code>]` section
Example fix
// before (config.toml) [languages.fr] # no translations table // after [languages.fr] [languages.fr.translations] title = "Titre"
Defensive patterns
Strategy: validation
Validate before calling
let lang = "fr"; let key = "title";
let defined = config.languages.get(lang)
.map(|o| o.translations.contains_key(key))
.unwrap_or(false);
if !defined { /* fallback to default-language translation or fix config */ } Type guard
fn translation_exists(config: &Config, lang: &str, key: &str) -> bool {
config.languages.get(lang).map(|o| o.translations.contains_key(key)).unwrap_or(false)
} Try / catch
match config.get_translation(lang, key) {
Ok(t) => t,
Err(e) if e.to_string().contains("is missing") => default_translation_for(key),
Err(e) => return Err(e),
} Prevention
- Keep translations for every language in sync; diff keys across [languages.*.translations] sections
- Centralize key names as constants instead of ad-hoc strings in templates
- Test templates that call trans() for each configured language in CI
When it happens
Trigger: Calling `get_translation(lang, key)` (directly or via the `trans(key, lang)` template function) where `config.languages[lang].translations` has no entry for `key`.
Common situations: Typo in the translation key used in a template vs config.toml; key defined for the default language but not for an added `[languages.xx]`; forgetting to add the `translations` table for a new language; calling `trans` before translations were loaded.
Related errors
- Failed to find directory containing the config file.
- Cannot merge config.toml with theme.toml because the followi
- Invalid filter type : {filter}. Valid values: nearest, trian
- {} not found in current directory or ancestors, current_dir
- zola.toml (or config.toml) not found in current directory or
AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03).
Data as JSON: /api/errors/1d7a1f7efd838332.
Report an issue: GitHub.