-
Notifications
You must be signed in to change notification settings - Fork 808
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
Extensions: drop i18n wrapper #11743
Conversation
Do we now need to add |
ab043d7
to
780b1d1
Compare
Yes, I believe so. |
This could do the trick function addTextdomain( j, root, name ) {
return root
.find( j.CallExpression, { callee: { type: 'Identifier', name } } )
.forEach( path => {
j( path ).replaceWith( () => {
path.node.arguments = path.node.arguments.concat( j.stringLiteral( 'jetpack' ) );
return path.node;
} );
} )
.toSource( { quote: 'single' } );
}
export default function transformer( file, api ) {
const j = api.jscodeshift;
var ret = file.source;
ret = addTextdomain( j, j( ret ), '__' );
ret = addTextdomain( j, j( ret ), '_n' );
ret = addTextdomain( j, j( ret ), '_x' );
ret = addTextdomain( j, j( ret ), '_nx' );
return ret;
} |
9c94a12
to
2d67304
Compare
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 2, 2019. |
2d67304
to
40e357e
Compare
Rebased after |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try and produce a WP.com phab diff. |
D26251-code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and it worked as expected. I tried switching branches and everything continued to work. Code looks good too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works well for me 👍
Thanks everyone for reviewing! |
Closes: #11656
Changes proposed in this Pull Request:
extensions/utils
__, _n, _x, _nx()
imports to import directly from@wordpress/i18n
jetpack
textdomain as last argument to all those functionsTesting instructions:
Proposed changelog entry for your changes:
Blocks: Drop i18n wrapper, use
@wordpress/i18n
directly.