How to set the language for diagnostic messages
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
I want to dynamically set the language of diagnostic information based on the user's region.
But I didn't find the corresponding API.
I know using `ts.validateLocaleAndSetLanguage`.
it doesn't work in ts-morph.
But it is indeed valid in typescript.
Is there any other method provided in ts-morph that I don't know about?
```ts
import { Project, ts } from 'ts-morph';
ts.validateLocaleAndSetLanguage('zh-cn', ts.sys);
export const project = new Project({
compilerOptions: {
target: ScriptTarget.ES2015,
},
});
const sourceFile = project.createSourceFile('test.ts', 'const a;', { overwrite: true });
const diagonstics = sourceFile.getPreEmitDiagnostics();
diagonstics[0].getMessageText();
```
Contributor guide
Research direction
The issue provides a TypeScript reproduction using ts.validateLocaleAndSetLanguage, Project, createSourceFile, and getPreEmitDiagnostics; start by running it and tracing how ts-morph obtains diagnostic messages. No repository file or test is named, so identify the diagnostic-language entry point and define done as a supported way to select the locale with the resulting message reflecting it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100