blob: 9de6aa94f0110f9dfc804ed28520ae421c7378f1 [file] [log] [blame]
Ankush Menat67e64722021-04-16 21:44:49 +05301# Examples taken from https://frappeframework.com/docs/user/en/translations
2# This file is used for testing the tests.
3
4from frappe import _
5
6full_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
19subscribers = ["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
35msg = _(" You have {0} pending invoice ")
36# ruleid: frappe-translation-trailing-spaces
37msg = _("You have {0} pending invoice ")
38# ruleid: frappe-translation-trailing-spaces
39msg = _(" You have {0} pending invoice")
40
41# ok: frappe-translation-trailing-spaces
42msg = ' ' + _("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 Menat073dcf72021-05-25 14:06:10 +053054
55
56class Test:
57 # ok: frappe-translation-python-splitting
58 def __init__(
59 args
60 ):
61 pass