lokalise / i18n-ally

🌍 All in one i18n extension for VS Code
https://marketplace.visualstudio.com/items?itemName=lokalise.i18n-ally
MIT License
3.92k stars 311 forks source link

`next-intl` Double Quotation Marks for Extraction of Keys #1074

Open codesfromshad opened 8 months ago

codesfromshad commented 8 months ago

Is your feature related to a specific framework or general for this extension

Feature related to next-intl.

Is your feature request related to a problem? Please describe.

Extraction for double quotation marks is not supported.

Describe the solution you'd like

A small change here will enable support for double quotation marks.

...
  refactorTemplates(keypath: string) {
    // Ideally we'd automatically consider the namespace here. Since this
    // doesn't seem to be possible though, we'll generate all permutations for
    // the `keypath`. E.g. `one.two.three` will generate `three`, `two.three`,
    // `one.two.three`.

    const keypaths = keypath.split('.').map((cur, index, parts) => {
      return parts.slice(parts.length - index - 1).join('.')
    })
    return [
      ...keypaths.map(cur =>
        `{t("${cur}")}`,
      ),
      ...keypaths.map(cur =>
        `{t('${cur}')}`,
      ),
      ..keypaths.map(cur =>
        `t("${cur}")`,
      ),
      ...keypaths.map(cur =>
        `t('${cur}')`,
      ),
    ]
  }
...

Additional context

Option to choose ", ', or, ` while extracting would be nice.

codesfromshad commented 8 months ago

@amannn Would you please kindly take a look at this?

amannn commented 8 months ago

I think this might be better addressed by running prettier/eslint on save after the adjustment from i18n-ally. Other frameworks don't include permutations for all quotation marks that JS supports either, I think it would unnecessarily clutter the suggestions and users have different preferences here.

But that's only my 2c!

codesfromshad commented 8 months ago

Is there any way it can be implemented? Through the configs perhaps? You do have a point though, it will become cluttered. But giving the plugin users that option, without the added step from ESLint would be nice.

felixhaeberle commented 7 months ago

@codesfromshad hey, as i18n-ally seems unmaintained and nobody is answering the issues here, I would advise you to use the inlang vscode extension: https://marketplace.visualstudio.com/items?itemName=inlang.vs-code-extension – we offer exactly what you are asking for.

It also has an integration guide on the next-intl website: https://next-intl-docs.vercel.app/docs/workflows/vscode-integration#inlang

PS: I'm the maintainer of the inlang extension; we're happy to work with our community to make the extension better every day in our discord: https://discord.com/channels/897438559458430986/1084866749842870333

codesfromshad commented 7 months ago

@codesfromshad hey, as i18n-ally seems unmaintained and nobody is answering the issues here, I would advise you to use the inlang vscode extension: https://marketplace.visualstudio.com/items?itemName=inlang.vs-code-extension – we offer exactly what you are asking for.

It also has an integration guide on the next-intl website: https://next-intl-docs.vercel.app/docs/workflows/vscode-integration#inlang

PS: I'm the maintainer of the inlang extension; we're happy to work with our community to make the extension better every day in our discord: https://discord.com/channels/897438559458430986/1084866749842870333

Out of the box support for next-intl? Sounds great!