{"record":{"id":"2e57ddb60555e206","repo":"mozilla/pdf.js","slug":"app-language-is-read-only","errorCode":null,"errorMessage":"app.language is read-only","messagePattern":"app\\.language is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/app.js","lineNumber":257,"sourceCode":"  }\n\n  get fs() {\n    return (this._fs ??= new Proxy(\n      new FullScreen({ send: this._send }),\n      this._proxyHandler\n    ));\n  }\n\n  set fs(_) {\n    throw new Error(\"app.fs is read-only\");\n  }\n\n  get language() {\n    return this._language;\n  }\n\n  set language(_) {\n    throw new Error(\"app.language is read-only\");\n  }\n\n  get media() {\n    return undefined;\n  }\n\n  set media(_) {\n    throw new Error(\"app.media is read-only\");\n  }\n\n  get monitors() {\n    return [];\n  }\n\n  set monitors(_) {\n    throw new Error(\"app.monitors is read-only\");\n  }\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/app.js#L239-L275","documentation":"app.language returns the viewer's resolved language string (this._language). It reflects the host locale and is not user-writable, so the setter throws. The throw guards the locale source-of-truth held by the viewer.","triggerScenarios":"PDF-embedded JavaScript or caller executes app.language = 'FRA' (or any value); the setter at src/scripting_api/app.js:257 throws unconditionally.","commonSituations":"Scripts trying to force a UI language from within the document; localization tests that mistakenly write instead of configuring the viewer.","solutions":["Set the desired locale at the viewer/host level (e.g., PDF.js locale init), not via app.language.","Read app.language to branch document behavior per locale.","Pass language preferences through viewer configuration before document load."],"exampleFix":"// before\napp.language = 'FRA';\n// after\n// configure pdf.js with the fr locale at startup; then:\nif (app.language === 'FRA') { /* ... */ }","handlingStrategy":"validation","validationCode":"// app.language reflects host locale; configure via viewer init.\nfunction pickLabel(app, dict) { return dict[app.language] ?? dict.default; }","typeGuard":"const isLanguageString = (v) => typeof v === 'string' && /^[A-Z]{3}$/.test(v);","tryCatchPattern":"try { /* code that may assign app.language */ }\ncatch (e) { if (!/language is read-only/.test(e.message)) throw e; }","preventionTips":["Set locale at viewer startup, not from document JS.","Branch on app.language rather than trying to change it.","Pass desired locale through pdf.js configuration."],"tags":["scripting-api","read-only","i18n","acrobat-js"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}