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

Report empty textdomains in i18n #1948

Closed
kkmuffme opened this issue Sep 8, 2020 · 3 comments · Fixed by #2214
Closed

Report empty textdomains in i18n #1948

kkmuffme opened this issue Sep 8, 2020 · 3 comments · Fixed by #2214

Comments

@kkmuffme
Copy link

kkmuffme commented Sep 8, 2020

esc_html_e( 'foo', '' );

should be reported as an error, since the textdomain should not be empty (it can be, but in 99.99% of cases this is unwanted)
Same for __(), _x(),...

@jrfnl
Copy link
Member

jrfnl commented Sep 8, 2020

The I18n sniff will report this correctly - Mismatched text domain. Expected 'my-plugin' but got ''. - as soon as you either pass a text-domain via a custom ruleset or via the command-line.

This sniff is also used by WP Core and for WP Core, usage without a text-domain is valid and - as the $text_domain variable is optional with a default of '', using it like in the above code sample is too.

@kkmuffme
Copy link
Author

kkmuffme commented Sep 8, 2020

Thx, had a mistake on our end not passing the textdomain correctly anymore

@kkmuffme kkmuffme closed this as completed Sep 8, 2020
@jrfnl jrfnl reopened this Mar 18, 2023
@jrfnl jrfnl added this to the 3.0.0 milestone Mar 18, 2023
@jrfnl
Copy link
Member

jrfnl commented Mar 18, 2023

Looks like the default value for the $domain parameter is now 'default' instead of an empty string for nearly all translation functions.

This means that passing an empty string is no longer a valid action as it would overrule the default value for the parameter and make the text string untranslatable.

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