Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useTranslation with t does not get detected by i18n-ally #823

Closed
AmruthPillai opened this issue Oct 19, 2022 · 1 comment · Fixed by #871
Closed

useTranslation with t does not get detected by i18n-ally #823

AmruthPillai opened this issue Oct 19, 2022 · 1 comment · Fixed by #871
Labels
bug Something isn't working

Comments

@AmruthPillai
Copy link

AmruthPillai commented Oct 19, 2022

Describe the bug

When using the extension, and the i18next hook provided in the following way: const { t } = useTranslation(), i18n-ally is not able to detect t as a valid function to translate.

Works:

i18n.t("key")

Doesn't Work:

t("key")

Extension Version

i18n-ally v2.8.1

Framework/i18n package you are using

react-i18next (with Vite)

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'=
  3. See error

Device Infomation

  • OS: MacOS
  • Version: 12.6
  • VS Code Version: 1.72.2

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

🧰 Config "i18n-ally.pathMatcher" changed, reloading
🔁 Reloading loader
🧩 Enabled frameworks: i18next
🧬 Enabled parsers: json

🚀 Initializing loader "..."
📂 Directory structure: dir
🗃 Custom Path Matcher: {locale}/{namespaces}.json
🗃 Path Matcher Regex: /^(?<locale>[\w-_]+)\/(?<namespace>.+)\.json$/

📂 Loading locales under .../src/i18n/locales
	📑 Loading (de) de/assets.json [1664274280419.1033]
	📑 Loading (de) de/calendar.json [1666167744706.3545]
	📑 Loading (de) de/common.json [1666174113886.896]
	📑 Loading (de) de/consumables.json [1666171898841.2483]
	📑 Loading (de) de/contacts.json [1666167744706.7852]
	📑 Loading (de) de/data-view.json [1665477033145.4875]
	📑 Loading (de) de/navigation.json [1664451494489.8552]
	📑 Loading (de) de/notifications.json [1665646808550.8687]
	📑 Loading (de) de/settings.json [1666167749246.1184]
	📑 Loading (de) de/tasks.json [1666173988235.9185]
	📑 Loading (en) en/assets.json [1664457365018.2834]
	📑 Loading (en) en/calendar.json [1666167744707.4556]
	📑 Loading (en) en/common.json [1666174184095.2964]
	📑 Loading (en) en/consumables.json [1666167744707.7578]
	📑 Loading (en) en/contacts.json [1666167744707.8425]
	📑 Loading (en) en/data-view.json [1665477033146.1714]
	📑 Loading (en) en/navigation.json [1663336386482.9387]
	📑 Loading (en) en/notifications.json [1665646808551.188]
	📑 Loading (en) en/settings.json [1666167749246.307]
	📑 Loading (en) en/tasks.json [1666173847832.7754]

👀 Watching change on /Users/amruth/Projects/Elara/app/apps/web/src/i18n/locales
✅ Loading finished

Screenshots

Screenshot 2022-10-19 at 12 26 58 PM

@AmruthPillai AmruthPillai added the bug Something isn't working label Oct 19, 2022
@aubert-creation
Copy link

I think the bug is not exactly with t('...') and i18n.t('...') but when we use a namespace in a t / i18n.t function.

try with

const { t } = useTranslation('tasks');
{t("checklist.inspection.states.passed_with_remarks")}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants