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

Check that all text strings are translated and in the same language #33

Open
1 task
jrfnl opened this issue Jul 18, 2016 · 4 comments
Open
1 task

Check that all text strings are translated and in the same language #33

jrfnl opened this issue Jul 18, 2016 · 4 comments

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Jul 18, 2016

Rule type:

Error

Rule:

From what I can see, there are actually 5 distinct i18n related rules which may need sniffs - this issue covers the first and fourth item on the list.

  1. All theme text strings are to be translatable.
  2. Include a text domain in style.css ([New Sniff] Check that style.css contain a text-domain entry. #34)
  3. Use a single unique theme slug – as the theme slug appears in style.css. If it uses a framework then no more than 2 unique slugs. ([Implement Sniff] Check that only one - or at most two - text-domains are used in the theme #35)
  4. Can use any language for text, but only use the same one for all text.
  5. Correct usage of the WP i18n functions. ([Implement sniff] Verify that the i18n functions are used properly #31)

Refs:
https://make.wordpress.org/themes/handbook/review/required/#language
https://make.wordpress.org/themes/handbook/review/required/theme-check-plugin/#additional-checks

Checking whether all text strings are translatable is very tricky as the echo call and the string building aren't always done in the same place. Strings within PHP are often enough also used for other purposes - think array indexes -, so it is doubtful this can be implemented in the form of a sniff.

The Pig Latin plugin comes to mind as a useful tool to check this, but this is a tool that checks at runtime in contrast to PHPCS which does a static code analysis.

Similarly, checking whether all text strings are in the same languages would be a very interesting challenge to.

I believe these will remain manual check.

All the same: ideas welcome ;-)

Theme check file covering this rule:

n/a

Decision needed:

Request for decision: Is it acceptable that this will stay a manual check ?

To do:

  • ... ?
@grappler
Copy link
Member

I think this will be a difficult check to run. Even with Pig Latin you need to do a manual check for which strings are not being converted.

These are the three main forms that I could think of that we would need to catch.

<span>Hello World</span>
echo 'Hello World!'
array (
    'title' => 'Hello World!',
)

We could help the manuall check by listing strings that need to be check. This would change the check from an ERROR to a WARNING.

Let's keep this as low priorty at the moment.

@dingo-d
Copy link
Member

dingo-d commented May 18, 2019

Do we want to work on this, or can we close this issue?

@jrfnl
Copy link
Contributor Author

jrfnl commented May 19, 2019

The "check that all translatable strings are in the same language" bit may be sniffable if we could do some sort of dictionary check, possibly using the PHP ICU extension, but the "check that all text strings are translatable" bit is neigh impossible to sniff for.

@jrfnl
Copy link
Contributor Author

jrfnl commented May 19, 2019

All the same, if at all, this should probably be addressed in WPCS itself. Not sure if an upstream issue exists for this yet.

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