Ankush Menat | 67e6472 | 2021-04-16 21:44:49 +0530 | [diff] [blame] | 1 | rules: |
| 2 | - id: frappe-translation-empty-string |
| 3 | pattern-either: |
| 4 | - pattern: _("") |
| 5 | - pattern: __("") |
| 6 | message: | |
| 7 | Empty string is useless for translation. |
| 8 | Please refer: https://frappeframework.com/docs/user/en/translations |
| 9 | languages: [python, javascript, json] |
| 10 | severity: ERROR |
| 11 | |
| 12 | - id: frappe-translation-trailing-spaces |
| 13 | pattern-either: |
| 14 | - pattern: _("=~/(^[ \t]+|[ \t]+$)/") |
| 15 | - pattern: __("=~/(^[ \t]+|[ \t]+$)/") |
| 16 | message: | |
| 17 | Trailing or leading whitespace not allowed in translate strings. |
| 18 | Please refer: https://frappeframework.com/docs/user/en/translations |
| 19 | languages: [python, javascript, json] |
| 20 | severity: ERROR |
| 21 | |
| 22 | - id: frappe-translation-python-formatting |
| 23 | pattern-either: |
| 24 | - pattern: _("..." % ...) |
| 25 | - pattern: _("...".format(...)) |
| 26 | - pattern: _(f"...") |
| 27 | message: | |
| 28 | Only positional formatters are allowed and formatting should not be done before translating. |
| 29 | Please refer: https://frappeframework.com/docs/user/en/translations |
| 30 | languages: [python] |
| 31 | severity: ERROR |
| 32 | |
| 33 | - id: frappe-translation-js-formatting |
| 34 | patterns: |
| 35 | - pattern: __(`...`) |
| 36 | - pattern-not: __("...") |
| 37 | message: | |
| 38 | Template strings are not allowed for text formatting. |
| 39 | Please refer: https://frappeframework.com/docs/user/en/translations |
| 40 | languages: [javascript, json] |
| 41 | severity: ERROR |
| 42 | |
| 43 | - id: frappe-translation-python-splitting |
| 44 | pattern-either: |
Ankush Menat | b1f8c80 | 2021-05-11 18:27:20 +0530 | [diff] [blame] | 45 | - pattern: _(...) + _(...) |
Ankush Menat | 67e6472 | 2021-04-16 21:44:49 +0530 | [diff] [blame] | 46 | - pattern: _("..." + "...") |
Ankush Menat | 073dcf7 | 2021-05-25 14:06:10 +0530 | [diff] [blame] | 47 | - pattern-regex: '[\s\.]_\([^\)]*\\\s*' # lines broken by `\` |
| 48 | - pattern-regex: '[\s\.]_\(\s*\n' # line breaks allowed by python for using ( ) |
Ankush Menat | 67e6472 | 2021-04-16 21:44:49 +0530 | [diff] [blame] | 49 | message: | |
| 50 | Do not split strings inside translate function. Do not concatenate using translate functions. |
| 51 | Please refer: https://frappeframework.com/docs/user/en/translations |
| 52 | languages: [python] |
| 53 | severity: ERROR |
| 54 | |
| 55 | - id: frappe-translation-js-splitting |
| 56 | pattern-either: |
Ankush Menat | b1f8c80 | 2021-05-11 18:27:20 +0530 | [diff] [blame] | 57 | - pattern-regex: '__\([^\)]*[\\]\s+' |
| 58 | - pattern: __('...' + '...', ...) |
Ankush Menat | 67e6472 | 2021-04-16 21:44:49 +0530 | [diff] [blame] | 59 | - pattern: __('...') + __('...') |
| 60 | message: | |
| 61 | Do not split strings inside translate function. Do not concatenate using translate functions. |
| 62 | Please refer: https://frappeframework.com/docs/user/en/translations |
| 63 | languages: [javascript, json] |
| 64 | severity: ERROR |