lokalise / i18n-ally

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

Support for custom namespace hooks #813

Open AlbertSmit opened 2 years ago

AlbertSmit commented 2 years ago

Is your feature related to a specific framework or general for this extension Sort of, it's for Custom.

Is your feature request related to a problem? Please describe. We have a custom hook to set namespaces, much like i18next's useTranslation hook, except named differently. Essentially, it just concat's the strings, and looks it up in a file with keys.

Example pseudo-code given:

  const i18n = useI18n('namespace')
  const copy = i18n('key-to-be-translated')

Describe the solution you'd like I'd like to be able to pass on a regex string in the config to indicate to look for this hook. I see in the frameworks folder that i18next practically has this setup (getScopeRange). Having it be configurable with regex would be a great addition!

Example RegExp given:

  { 
    // ...
    "i18n-ally.regex.scopeRangeRegex": "[^\\w\\d]useI18n\\(['\"`]({key})['\"`]\\)"
    // ...
  }
aranard commented 1 year ago

I would also love to see this configuration added! I'm using react-i18next but have a custom hook that abstracts useTranslation, so would like to be able to set the scope text that getScopeRange is looking for to a custom value.