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

Support for referencing Objects in T helper #42

Open
MarkLunney opened this issue Feb 2, 2024 · 0 comments
Open

Support for referencing Objects in T helper #42

MarkLunney opened this issue Feb 2, 2024 · 0 comments

Comments

@MarkLunney
Copy link

It would be convenient to be define strings values in an Object and be able to reference the values using the T helper:

const Pets = {
  cat: "Cat",
  dog: "Dog",
};

return T(Pets.cat)

This currently throws the following error:

yarn extract-strings --outfile=./src/i18n/en/strings.json "src/**/!(*.test|*.d).{ts,tsx}"
yarn run v1.22.19
Extracting strings from '[redacted]' + 1597 other files...
undefined:3
return Pets.cat
^

ReferenceError: Pets is not defined
    at eval (eval at evaluate ([redacted]/node_modules/t-i18n/scripts/extract-strings.js:21:22), <anonymous>:3:1)

The following doesn't produce the same error:

const cat = "Cat";

return T(cat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant