angular/angular · error · Error
Invalid Locale: '${locale}' is not a valid locale.
Error message
Invalid Locale: '${locale}' is not a valid locale. What it means
Error "Invalid Locale: '${locale}' is not a valid locale." thrown in angular/angular.
Source
Thrown at packages/localize/tools/src/translate/output_path.ts:31
*/
export interface OutputPathFn {
(locale: string, relativePath: string): string;
}
/**
* Create a function that will compute the absolute path to where a translated file should be
* written.
*
* The special `{{LOCALE}}` marker will be replaced with the locale code of the current translation.
* @param outputFolder An absolute path to the folder containing this set of translations.
*/
export function getOutputPathFn(fs: PathManipulation, outputFolder: AbsoluteFsPath): OutputPathFn {
const [pre, post] = outputFolder.split('{{LOCALE}}');
return post === undefined
? (_locale, relativePath) => fs.join(pre, relativePath)
: (locale, relativePath) => {
if (/[\/\\]|\.\./.test(locale)) {
throw new Error(`Invalid Locale: '${locale}' is not a valid locale.`);
}
const outputPath = fs.join(pre + locale + post, relativePath);
const resolvedOutputPath = fs.resolve(outputPath);
const resolvedPre = fs.resolve(pre);
if (!resolvedOutputPath.startsWith(resolvedPre)) {
throw new Error(`Invalid Locale: '${locale}' would cause path traversal.`);
}
return outputPath;
};
}
View on GitHub (pinned to 51cb07e980)
Solutions
- Use a valid BCP 47 locale code, e.g. en-US, fr, de-DE.
When it happens
Trigger: Thrown at packages/localize/tools/src/translate/output_path.ts:31 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of angular/angular@51cb07e980 (2026-08-22).
Data as JSON: /api/errors/8042e79f840b6589.
Report an issue: GitHub.