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

Better identify translator's comments in built files. #106

Closed
herregroen opened this issue Nov 9, 2018 · 2 comments
Closed

Better identify translator's comments in built files. #106

herregroen opened this issue Nov 9, 2018 · 2 comments

Comments

@herregroen
Copy link
Contributor

Currently when parsing files built by WebPack some translator's comments aren't being picked up yet due to how webpack outputs these.

For example:
image

It seems WebPack will always attach comments to the previous statement rather than prepend them.

JS parsing should either be updated to correctly identify these translator's comments or it should be investigated if WebPack can be configured to correctly output comments and in this case documentation published on how to do this.

@swissspidy
Copy link
Member

JS parsing should either be updated to correctly identify these translator's comments or it should be investigated if WebPack can be configured to correctly output comments and in this case documentation published on how to do this.

I prefer the latter.

Even better would be if we could actually parse the source files for core, otherwise the source code reference is pretty much useless for translators. But that's something for another issue :-)

@anomiex
Copy link

anomiex commented Dec 12, 2021

You might move the comment closer to the __() call to reduce the chances that it will get dropped or misplaced as the code is transformed.

So instead of

// translators: Some comment
label={ sprintf( __( 'msgid', 'domain' ), arg ) }

try this instead

label={
    // translators: Some comment
    sprintf( __( 'msgid', 'domain' ), arg )
}

or even this

label={
    sprintf(
        // translators: Some comment
        __( 'msgid', 'domain' ),
        arg
    )
}

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

4 participants