Ankush Menat | 67e6472 | 2021-04-16 21:44:49 +0530 | [diff] [blame] | 1 | # Examples taken from https://frappeframework.com/docs/user/en/translations |
| 2 | # This file is used for testing the tests. |
| 3 | |
| 4 | from frappe import _ |
| 5 | |
| 6 | full_name = "Jon Doe" |
| 7 | # ok: frappe-translation-python-formatting |
| 8 | _('Welcome {0}, get started with ERPNext in just a few clicks.').format(full_name) |
| 9 | |
| 10 | # ruleid: frappe-translation-python-formatting |
| 11 | _('Welcome %s, get started with ERPNext in just a few clicks.' % full_name) |
| 12 | # ruleid: frappe-translation-python-formatting |
| 13 | _('Welcome %(name)s, get started with ERPNext in just a few clicks.' % {'name': full_name}) |
| 14 | |
| 15 | # ruleid: frappe-translation-python-formatting |
| 16 | _('Welcome {0}, get started with ERPNext in just a few clicks.'.format(full_name)) |
| 17 | |
| 18 | |
| 19 | subscribers = ["Jon", "Doe"] |
| 20 | # ok: frappe-translation-python-formatting |
| 21 | _('You have {0} subscribers in your mailing list.').format(len(subscribers)) |
| 22 | |
| 23 | # ruleid: frappe-translation-python-splitting |
| 24 | _('You have') + len(subscribers) + _('subscribers in your mailing list.') |
| 25 | |
| 26 | # ruleid: frappe-translation-python-splitting |
| 27 | _('You have {0} subscribers \ |
| 28 | in your mailing list').format(len(subscribers)) |
| 29 | |
| 30 | # ok: frappe-translation-python-splitting |
| 31 | _('You have {0} subscribers') \ |
| 32 | + 'in your mailing list' |
| 33 | |
| 34 | # ruleid: frappe-translation-trailing-spaces |
| 35 | msg = _(" You have {0} pending invoice ") |
| 36 | # ruleid: frappe-translation-trailing-spaces |
| 37 | msg = _("You have {0} pending invoice ") |
| 38 | # ruleid: frappe-translation-trailing-spaces |
| 39 | msg = _(" You have {0} pending invoice") |
| 40 | |
| 41 | # ok: frappe-translation-trailing-spaces |
| 42 | msg = ' ' + _("You have {0} pending invoices") + ' ' |
| 43 | |
| 44 | # ruleid: frappe-translation-python-formatting |
| 45 | _(f"can not format like this - {subscribers}") |
| 46 | # ruleid: frappe-translation-python-splitting |
| 47 | _(f"what" + f"this is also not cool") |
| 48 | |
| 49 | |
| 50 | # ruleid: frappe-translation-empty-string |
| 51 | _("") |
| 52 | # ruleid: frappe-translation-empty-string |
| 53 | _('') |
Ankush Menat | 073dcf7 | 2021-05-25 14:06:10 +0530 | [diff] [blame] | 54 | |
| 55 | |
| 56 | class Test: |
| 57 | # ok: frappe-translation-python-splitting |
| 58 | def __init__( |
| 59 | args |
| 60 | ): |
| 61 | pass |