lokalise / i18n-ally-jetbrains-docs

6 stars 4 forks source link

Support for TypeScript type literal objects (`as const`) #47

Open kolkinn opened 1 year ago

kolkinn commented 1 year ago

In v23 of i18next, they added the ability to infer interpolation values in TypeScript. This feature requires the object that is exported in a *.ts file to have as const appended to the declaration, like in the example below: https://github.com/i18next/i18next/blob/master/examples/typescript/i18n/en/ns1.ts

In my current project we have been using *.ts files for our translations, which has worked well with i18n Ally. These look like this:

export default {
  color: {
    green: "Green",
    red: "Red",
  },
  close: "Close",
  submit: "Submit",
};

As soon as I added as const at the end, i18n Ally complained.

export default {
  color: {
    green: "Green",
    red: "Red",
  },
  close: "Close",
  submit: "Submit",
- };
+ } as const;

Would it be possible for i18n Ally to support this format by ignoring the as const part?