-
Notifications
You must be signed in to change notification settings - Fork 60
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
Plugin i18n check complains about default
text domain
#713
Comments
Explicitly allowed, or just tolerated? Where is this written? If it‘s not written anywhere I‘d suggest the plugins team to do that first.
Nowadays this is not really true anymore. Translators can simply copy those strings with a single click. FWIW, personally I have never really been a fan of reusing core strings, as it has more downsides than upsides. |
This is part of WPCS for example: https://github.com/WordPress/WordPress-Coding-Standards/blob/2133137c33fa898df70b5f879a65d83af4dbb97d/WordPress/Sniffs/WP/I18nSniff.php#L479
That's still more work than doing nothing. Why would we want people to copy translations from somewhere else when we can reuse existing ones that are established?
What are the downsides? 🤔 |
I could go on :-) Point is, using core strings should be a really rare thing that one should only do if they know the consequences. That means PCP should still warn about it. You can ignore the warnings or skip the check in that case. |
Those are fair points. Though if you know what you're doing, some of the points may not actually be downsides. Per your last note, we should probably adjust this to be a warning then. Right now, using the |
In this respect there are two casuistries:
One of the solutions might be to check if the string to translate is really part of the core translations. If it is: Warning? , if it isn't: Error. The existence of the translated string could perhaps be checked directly with a call to WordPress core? In any case since the core strings can be easily exported to a PHP array, that could be another possibility. |
Good point, it‘s an important distinction.
Interesting idea, but that requires extra maintenance of such a (giant!) PHP file somewhere in the plugin. And strings change a lot between releases, so this is infeasible IMO. I‘d say:
|
I think is a rare case of using |
To make use of the |
I don't think there's a configuration for this (and I doubt WPCS would add one), so yeah probably need to parse the error message. |
I'm also seeing an unexpected __( 'Quote from Hello Dolly song, by Jerry Herman:', 'hello-dolly' ), The admin shows Seems related, but if this should be an entirely different ticket, please let me know. |
That indeed sounds like it warrants its own ticket, if you don‘t mind :) Thanks for raising! |
@ironprogrammer I tried to reproduce the error you mentioned in my local setup. Can you please elaborate the steps to reproduce the issue? |
@ernilambar, thanks for the follow-up. The issue occurred when the file was in the When the plugin was moved into its own directory, then the text domain checks worked as expected. Unless PCP is intended to be used on plugins installed in the |
@ironprogrammer Thanks for the update. Although WordPress plugin directory does not accept single file plugin, PCP theoretically supports single file plugin. Mismatched textdomain check is not supposed to be triggered because we have kept that in the conditional checking |
I just noticed that as of 1.2.0, the Plugin Check complains about usage of the
default
text domain in plugins. I believe that this is not correct. It is explicitly allowed to use WordPress Core's text domain if it is for strings that are taken directly from Core. Not doing so creates unnecessary work for translators.It looks like the relevant change was made in #681. I believe we need to update that code so that in addition to the plugin's own text domain we pass
default
there so that it is allowed too.Here's the example where I noticed this check suddenly failing: https://github.com/felixarntz/ai-services/actions/runs/11282317040/job/31379501989?pr=11
It is worth noting that this was also automatically flagged during the review of that plugin when I submitted it to the directory, however after clarification it was allowed. So this confirms to me that this is simply a bug in the tooling, and we should allow
default
.cc @davidperezgar @ernilambar
The text was updated successfully, but these errors were encountered: