Open jrfnl opened 8 years ago
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.
Do we want to work on this, or can we close this issue?
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.
All the same, if at all, this should probably be addressed in WPCS itself. Not sure if an upstream issue exists for this yet.
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.
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: