Skip to content
New issue

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

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

Already on GitHub? # to your account

Problems with "Extract i18n key" using react-i18n #133

Open
gpsfl opened this issue Sep 9, 2021 · 1 comment
Open

Problems with "Extract i18n key" using react-i18n #133

gpsfl opened this issue Sep 9, 2021 · 1 comment

Comments

@gpsfl
Copy link

gpsfl commented Sep 9, 2021

Given the following example, I have encountered two problems when using the "Extract i18n key" feature:

const Component = () => {
    const {t} = useTranslation();
    return (<Text value="My string" />)
}
  1. If the string is not inside curly braces, it will throw an error:
kotlin.KotlinNullPointerException
	at com.eny.i18n.plugin.language.jsx.JsxTranslationExtractor.text(JsxLanguageFactory.kt:69)
	at com.eny.i18n.plugin.ide.actions.ExtractI18nIntentionAction.doInvoke(ExtractI18nIntentionAction.kt:52)
	at com.eny.i18n.plugin.ide.actions.ExtractI18nIntentionAction.access$doInvoke(ExtractI18nIntentionAction.kt:24)
	at com.eny.i18n.plugin.ide.actions.ExtractI18nIntentionAction$invoke$1.run(ExtractI18nIntentionAction.kt:36)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
  1. If the string is inside braces, it will extract the key. However the result use the i18n.t function instead of the existing t function from the translation hook. It will look like:
<Text value={i18n.t('key')} />
nyavro added a commit that referenced this issue Oct 3, 2021
#133 Problems with "Extract i18n key" using react-i18n
@nyavro
Copy link
Owner

nyavro commented Oct 30, 2021

@gpsfl have you checked if the problem still remains in 2.6.1?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants