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

[IMP] test_lint: add lint tests for translations #161842

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oomsveta
Copy link
Contributor

@oomsveta oomsveta commented Apr 15, 2024

Adds the following checks for translation antipatterns:

Pylint

  • Usage of _, _lt` function with multiple unnamed placeholders
  • Concatenation of translated text

ESLint

  • Usage of _t function with multiple unnamed placeholders
  • Concatenation of translated text

Python tests

  • .js files:
    • Backslash-newline in translated strings
  • .xml files:
    • Translated attributes as props
    • Human-readable text in Qweb directives
    • Call to _t in Owl templates

Task-3869533

Adds the following checks for translation antipatterns:
+ Usage of `_, `_lt` function with multiple unnamed placeholders
+ Concatenation of translated text
+ Usage of `_t` function with multiple unnamed placeholders
+ Concatenation of translated text
+ .js files:
  + Backslash-newline in translated strings
+ .xml files:
  + Translated attributes as props
  + Human-readable text in Qweb directives
  + Call to _t in Owl templates

Task-3869533
@robodoo
Copy link
Contributor

robodoo commented Apr 15, 2024

@C3POdoo C3POdoo added the RD research & development, internal work label Apr 15, 2024
Comment on lines +33 to +39
{
"selector": "CallExpression[callee.name='_t'] > :first-child[value=/(.*%s){2,}/]",
"message": "Usage of _t function with multiple unnamed placeholders"
},
{
"selector": "BinaryExpression[operator='+'] > CallExpression[callee.name='_t']",
"message": "Concatenation of translated text"
Copy link
Contributor

@odony odony Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to separate the rules and give them meaningful names like no-translations-concat and no-translation-unnamed-placeholders, rather than putting them under no-restricted-syntax. This way they can be selectively disabled, e.g with /* eslint-disable no-translations-concat */ or /* eslint-disable-next-line no-translations-concat */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants