Open Solexofficial opened 8 months ago
Is this related to https://github.com/marhali/easy-i18n/pull/345?
is very similar! but there is work with strings. with notation like i18n.key is not supported (
@JPilson can you please look at this? ☝️
@Solexofficial I'm not sure if I understood correct but you want to be able to access the key from an object, so that you have some sort of type safe with keys?
const translated = t('key')
but also
import i18n from '...'
...
const translated = t(i18n.key)
Is this what you want ?
It is very necessary that the translation be displayed when accessing the object key.🙏
en.json
{
"continue_key": "Continue"
}
export const i18n = {
continue_key: "Continue"
}
import i18n from '..'
const Component = () => {
return <button>{i18n.continue_key}</button>
}
was displayed as
import i18n from '..'
const Component = () => {
return <button>{'Continue'}</button>
}
I see, If get time I can look into it. I'm not promising anything and its not related to https://github.com/marhali/easy-i18n/pull/345
Unfortunately, https://github.com/marhali/easy-i18n/pull/345 we are talking about replacement in strings, but I ask you to add the ability to replace not only strings (Literal), but also objects (Member Expression). https://astexplorer.net/#/gist/3c971281dcfa5fb6015222bf3fed8cf8/b5bdf3d7301042ae1c9fea3f3c1cfc4ce892ea59
{i18n.continue} display like {Continue}
This will be very useful for most developers. Thank you!
up
Hello Marcel!👋 Can you make an improvement so that the display of the translation key is available not only for strings, like
"key"
but is also displayed when accessing an object (a certain pattern), for example{i18n.key}
. By analogy, when replacement occurs when calling the function{{t('key')}}
other plugins, but specifically for objects.file.tsx
How difficult is it to implement?