lokalise / i18n-ally

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

Prettier formatted code with line break not recognized by i18n-ally #1118

Open dBianchii opened 3 months ago

dBianchii commented 3 months ago

Describe the bug

image vs image

Extension Version

i18n Ally

Framework/i18n package you are using

next-international

To Reproduce Steps to reproduce the behavior: use this code snippet:

{t(
   "You are about to finish your shift and checkout Are you sure",
)}
  1. Go to '...'
  2. Click on '....'=
  3. See error

Device Infomation

Extension Log Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information

Screenshots

aldrin-dev commented 1 month ago

You need to create a file named i18n-ally-custom-framework.yml in the root of your project. This file adds support for "Namespace", "rich", and "raw". Additionally, it properly handles long lines that prettier splits into multiple lines.

//i18n-ally-custom-framework.yml
languageIds:
  - javascript
  - typescript
  - javascriptreact
  - typescriptreact

usageMatchRegex:
  - "[^\\w\\d]t\\(['\"`]({key})['\"`]\\)"
  - "[^\\w\\d]t\\s*\\(\\s*['\"`]({key})['\"`]\\s*\\)"
  - "[^\\w\\d]t\\.rich\\(['\"`]({key})['\"`]\\)"
  - "[^\\w\\d]t\\.rich\\s*\\(\\s*['\"`]({key})['\"`]\\s*\\)"
  - "[^\\w\\d]t\\.raw\\(['\"`]({key})['\"`]\\)"
  - "[^\\w\\d]t\\.raw\\s*\\(\\s*['\"`]({key})['\"`]\\s*\\)"

scopeRangeRegex: "(?:useTranslations\\(|getTranslations\\(|namespace:)\\s*['\"`](.*?)['\"`]"

monopoly: true
dBianchii commented 1 month ago

You need to create a file named i18n-ally-custom-framework.yml in the root of your project. This file adds support for "Namespace", "rich", and "raw". Additionally, it properly handles long lines that prettier splits into multiple lines.

//i18n-ally-custom-framework.yml
languageIds:
  - javascript
  - typescript
  - javascriptreact
  - typescriptreact

usageMatchRegex:
  - "[^\\w\\d]t\\(['\"`]({key})['\"`]\\)"
  - "[^\\w\\d]t\\s*\\(\\s*['\"`]({key})['\"`]\\s*\\)"
  - "[^\\w\\d]t\\.rich\\(['\"`]({key})['\"`]\\)"
  - "[^\\w\\d]t\\.rich\\s*\\(\\s*['\"`]({key})['\"`]\\s*\\)"
  - "[^\\w\\d]t\\.raw\\(['\"`]({key})['\"`]\\)"
  - "[^\\w\\d]t\\.raw\\s*\\(\\s*['\"`]({key})['\"`]\\s*\\)"

scopeRangeRegex: "(?:useTranslations\\(|getTranslations\\(|namespace:)\\s*['\"`](.*?)['\"`]"

monopoly: true

Hi, I added this to .vscode folder and no sucess. I reloaded my vscode but saw no changes. I also tried adding it to the root of my project

aldrin-dev commented 1 month ago

Adding it to the .vscode folder should work.

image