-
-
Notifications
You must be signed in to change notification settings - Fork 493
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 for proper usage of translation functions #50
Comments
Another article covering the same topic: http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ |
I think this was accidentally closed. |
@GaryJones interesting. PHP tokenizes that single string literal into two separate |
It seems we need to merge two tokens of type |
I guess that merging would need to be done for context args and so on too, not just the string being internationalized. <?php _x( 'Post', 'Holds the
fence up', 'text-domain' ); ?> |
@GaryJones how's #545? |
@westonruter #545 tested on my real and made-up code, and the error no longer appears. 👍 |
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
Related: * `Universal.Namespaces.OneDeclarationPerFile` - upstream Extra WordPress#6 * `Universal.Namespaces.DisallowCurlyBraceSyntax` - upstream Extra WordPress#4 * `Universal.Namespaces.DisallowDeclarationWithoutName` - upstream Extra WordPress#50 * `Universal.UseStatements.NoLeadingBackslash` - upstream Extra WordPress#46 * `Universal.UseStatements.LowercaseFunctionConst` - upstream Extra WordPress#58 * `Universal.Constants.LowercaseClassResolutionKeyword` - upstream Extra WordPress#72 * `Generic.WhiteSpace.IncrementDecrementSpacing` - issue WordPress#1511, upstream PHPCS WordPress#2172, WordPress#2174 * `Universal.Operators.DisallowStandalonePostIncrementDecrement` - upstream Extra WordPress#65 * `Universal.Constants.UppercaseMagicConstants` - upstream Extra WordPress#64
I had read that variables were discouraged from being used in the i18n functions. I assumed this was just to discourage them from being changed. Well, it's actually because some automated i18n tools will tokenize the PHP files to extract the textdomain from PHP without actually evaluating the file. See @markjaquith's blog post Translating WordPress Plugins and Themes: Don’t Get Clever.
So a sniff should be written which makes sure that translation functions have a text domain which is a literal string. The sniff should also ensure that variables are not being used for the text to be translated, or inside of the text to be translated.
The text was updated successfully, but these errors were encountered: