{"record":{"id":"8042e79f840b6589","repo":"angular/angular","slug":"invalid-locale-locale-is-not-a-valid-locale","errorCode":null,"errorMessage":"Invalid Locale: '${locale}' is not a valid locale.","messagePattern":"Invalid Locale: '(.+?)' is not a valid locale\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/localize/tools/src/translate/output_path.ts","lineNumber":31,"sourceCode":" */\nexport interface OutputPathFn {\n  (locale: string, relativePath: string): string;\n}\n\n/**\n * Create a function that will compute the absolute path to where a translated file should be\n * written.\n *\n * The special `{{LOCALE}}` marker will be replaced with the locale code of the current translation.\n * @param outputFolder An absolute path to the folder containing this set of translations.\n */\nexport function getOutputPathFn(fs: PathManipulation, outputFolder: AbsoluteFsPath): OutputPathFn {\n  const [pre, post] = outputFolder.split('{{LOCALE}}');\n  return post === undefined\n    ? (_locale, relativePath) => fs.join(pre, relativePath)\n    : (locale, relativePath) => {\n        if (/[\\/\\\\]|\\.\\./.test(locale)) {\n          throw new Error(`Invalid Locale: '${locale}' is not a valid locale.`);\n        }\n\n        const outputPath = fs.join(pre + locale + post, relativePath);\n        const resolvedOutputPath = fs.resolve(outputPath);\n        const resolvedPre = fs.resolve(pre);\n\n        if (!resolvedOutputPath.startsWith(resolvedPre)) {\n          throw new Error(`Invalid Locale: '${locale}' would cause path traversal.`);\n        }\n\n        return outputPath;\n      };\n}\n","sourceCodeStart":13,"sourceCodeEnd":45,"githubUrl":"https://github.com/angular/angular/blob/51cb07e98081ab7e4e84a9e0949266a8e19cca84/packages/localize/tools/src/translate/output_path.ts#L13-L45","documentation":"Error \"Invalid Locale: '${locale}' is not a valid locale.\" thrown in angular/angular.","triggerScenarios":"Thrown at packages/localize/tools/src/translate/output_path.ts:31 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid BCP 47 locale code, e.g. en-US, fr, de-DE."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"51cb07e98081ab7e4e84a9e0949266a8e19cca84","analyzedAt":"2026-08-22T07:04:54.531Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}