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 different looking Trans props #70

Closed
grydstedt opened this issue Jan 18, 2018 · 5 comments
Closed

Support different looking Trans props #70

grydstedt opened this issue Jan 18, 2018 · 5 comments

Comments

@grydstedt
Copy link

grydstedt commented Jan 18, 2018

For parsing the Trans key there are multiple valid ways of doing props:

<Trans i18nKey="key" />
<Trans i18nKey='key' />
<Trans i18nKey={"key"} />
<Trans i18nKey={'key'} />

Could we add those to the regex?

@grydstedt grydstedt changed the title Support different looking trans props Support different looking Trans props Jan 18, 2018
@cheton
Copy link
Member

cheton commented Jan 18, 2018

Sure! I will check how to fine tune this part:

const reTrans = new RegExp('<Trans([^]*?)>([^]*?)</\\s*Trans\\s*>', 'gim');
const reTransKey = new RegExp('[^]*i18nKey="([^"]+)"[^]*', 'im');

@grydstedt
Copy link
Author

grydstedt commented Jan 19, 2018

Awesome! while we're on that another great thing would be the ability to have custom component names and key prop name. We, for example, have a wrapper component that looks like this:

<I18N __t="key" />

It would be great if I could use custom names in that regex for Trans and i18nKey

@wichert
Copy link
Contributor

wichert commented Jan 19, 2018

FWIW I just submitted PR #71 which changes that code a bit and might make this easier.

@cheton
Copy link
Member

cheton commented Jan 20, 2018

v2.3.1 added context and count options for Trans
https://github.com/i18next/i18next-scanner/releases/tag/v2.3.1

v2.4.0 added support for using different component name and i18nKey prop:
https://github.com/i18next/i18next-scanner/releases/tag/v2.4.0

trans: {
    component: 'Trans',
    i18nKey: 'i18nKey',
    extensions: ['.js', '.jsx'],
    fallbackKey: true
}

@cheton cheton closed this as completed Jan 20, 2018
@grydstedt
Copy link
Author

You rock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants