{"record":{"id":"1d7a1f7efd838332","repo":"getzola/zola","slug":"translation-key-for-language-is-missing","errorCode":null,"errorMessage":"Translation key '{}' for language '{}' is missing","messagePattern":"Translation key '(.+?)' for language '(.+?)' is missing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/config/src/config/mod.rs","lineNumber":380,"sourceCode":"    }\n\n    pub fn enable_serve_mode(&mut self) {\n        self.mode = Mode::Serve;\n    }\n\n    pub fn enable_check_mode(&mut self) {\n        self.mode = Mode::Check;\n        // Disable syntax highlighting since the results won't be used and it is slow\n        self.markdown.highlighting = None;\n    }\n\n    pub fn get_translation(&self, lang: &str, key: &str) -> Result<String> {\n        if let Some(options) = self.languages.get(lang) {\n            options\n                .translations\n                .get(key)\n                .ok_or_else(|| {\n                    anyhow!(\"Translation key '{}' for language '{}' is missing\", key, lang)\n                })\n                .cloned()\n        } else {\n            bail!(\"Language '{}' not found.\", lang)\n        }\n    }\n\n    pub fn has_taxonomy(&self, name: &str, lang: &str) -> bool {\n        if let Some(lang_options) = self.languages.get(lang) {\n            lang_options.taxonomies.iter().any(|t| t.name == name)\n        } else {\n            false\n        }\n    }\n\n    pub fn serialize(&self, lang: &str) -> SerializedConfig<'_> {\n        let options = &self.languages[lang];\n","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/config/src/config/mod.rs#L362-L398","documentation":"`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.","triggerScenarios":"Calling `get_translation(lang, key)` (directly or via the `trans(key, lang)` template function) where `config.languages[lang].translations` has no entry for `key`.","commonSituations":"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.","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"],"exampleFix":"// before (config.toml)\n[languages.fr]\n# no translations table\n// after\n[languages.fr]\n[languages.fr.translations]\ntitle = \"Titre\"","handlingStrategy":"validation","validationCode":"let lang = \"fr\"; let key = \"title\";\nlet defined = config.languages.get(lang)\n    .map(|o| o.translations.contains_key(key))\n    .unwrap_or(false);\nif !defined { /* fallback to default-language translation or fix config */ }","typeGuard":"fn translation_exists(config: &Config, lang: &str, key: &str) -> bool {\n    config.languages.get(lang).map(|o| o.translations.contains_key(key)).unwrap_or(false)\n}","tryCatchPattern":"match config.get_translation(lang, key) {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"is missing\") => default_translation_for(key),\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["config","i18n","translations"],"backgroundTag":"missing-translation-key","analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}