1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
Languages view
==============
Here is the tale of languages. We will see how to create, find and edit
them.
Getting there
-------------
Launchpad Translations has a main page.
>>> admin_browser.open('http://translations.launchpad.dev/')
There we can find a link to browse and manage languages.
>>> admin_browser.getLink('18 languages').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages
Adding new languages
--------------------
Following the link from the translations main page, there is a form to
add new languages.
>>> admin_browser.getLink('Add new language').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/+add
Which detects an attempt to create duplicate Languages, such as Spanish,
which is already registered:
>>> browser.open('http://translations.launchpad.dev/+languages/es')
>>> print browser.url
http://translations.launchpad.dev/+languages/es
If someone tries to create a new language with the same language code,
the system detects it and warns the user.
>>> admin_browser.getControl('The ISO 639').value = 'es'
>>> admin_browser.getControl('English name').value = 'Foos'
>>> admin_browser.getControl('Add').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/+add
>>> for tag in find_tags_by_class(admin_browser.contents, 'message'):
... print tag.renderContents()
There is 1 error.
There is already a language with that code.
But, with a new language, it will succeed.
>>> browser.open('http://translations.launchpad.dev/+languages/foos')
Traceback (most recent call last):
...
NotFound:...
>>> admin_browser.getControl('The ISO 639').value = 'foos'
>>> admin_browser.getControl('English name').value = 'Foos'
>>> admin_browser.getControl('Add').click()
And the system forwards us to its main page:
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/foos
A normal user will not be able to see or use the url to add languages.
>>> user_browser.open('http://translations.launchpad.dev/+languages')
>>> print user_browser.url
http://translations.launchpad.dev/+languages
>>> user_browser.getLink('Add new language')
Traceback (most recent call last):
...
LinkNotFoundError
>>> user_browser.open(
... 'http://translations.launchpad.dev/+languages/+add')
Traceback (most recent call last):
...
Unauthorized:...
Searching for a language
------------------------
From the top languages page, anyone can find languages.
>>> browser.open('http://translations.launchpad.dev/+languages')
>>> print browser.url
http://translations.launchpad.dev/+languages
>>> text_search = browser.getControl(name='field.search_lang')
>>> text_search.value = 'Spanish'
>>> browser.getControl('Find language', index=0).click()
>>> print browser.url
http://translations.launchpad.dev/+languages/+index?field.search_lang=Spanish
Read language information
-------------------------
Following one of the found languages, we can see a brief information
about the selected language.
>>> browser.getLink('Spanish').click()
>>> print browser.url
http://translations.launchpad.dev/+languages/es
>>> print extract_text(find_portlet(browser.contents, 'Plural forms'
... ).renderContents())
Plural forms
Spanish has 2 plural forms:
Form 0 for 1.
Form 1 for 0, 2, 3, 4, 5, 6...
When ...
>>> translationteams_portlet = find_portlet(
... browser.contents, 'Translation teams')
>>> print translationteams_portlet
<...
...testing Spanish team...
...Just a testing team...
>>> countries_portlet = find_portlet(browser.contents, 'Countries')
>>> print countries_portlet
<...
...Argentina...
...Bolivia...
...Chile...
...Colombia...
...Costa Rica...
...Dominican Republic...
...Ecuador...
...El Salvador...
...Guatemala...
...Honduras...
...Mexico...
...Nicaragua...
...Panama...
...Paraguay...
...Peru...
...Puerto Rico...
...Spain...
...United States...
...Uruguay...
...Venezuela...
>>> topcontributors_portlet = find_portlet(
... browser.contents, 'Top contributors')
>>> print topcontributors_portlet
<...
...Carlos Perelló Marín...
Our test sample data does not know about plural forms of
Abkhazian and about countries where this language is spoken.
We will see a note about missing plural forms and a link to Rosetta
add question page for informing Rosetta admin about the right plural
form.
>>> browser.open('http://translations.launchpad.dev/+languages/ab')
>>> print extract_text(find_portlet(browser.contents, 'Plural forms'
... ).renderContents())
Plural forms
Unfortunately, Launchpad doesn't know the plural
form information for this language...
>>> print browser.getLink(id='plural_question').url
http://answers.launchpad.dev/launchpad/+addquestion
We will see a note that Launchpad does not know in which countries
this language is spoken and a link to add question page for informing
Rosetta admin about the countries where this page is officially spoken.
>>> countries_portlet = find_portlet(browser.contents, 'Countries')
>>> print countries_portlet
<...
Abkhazian is not registered as being spoken in any
country...
>>> print browser.getLink(id='country_question').url
http://answers.launchpad.dev/launchpad/+addquestion
Edit language information
-------------------------
Finally, there is the edit form to change language basic information.
>>> user_browser.open(
... 'http://translations.launchpad.dev/+languages/es')
>>> print user_browser.url
http://translations.launchpad.dev/+languages/es
A plain user is not able to reach it.
>>> user_browser.getLink('Administer')
Traceback (most recent call last):
...
LinkNotFoundError
>>> user_browser.open(
... 'http://translations.launchpad.dev/+languages/es/+admin')
Traceback (most recent call last):
...
Unauthorized:...
An admin, though, will see the link and will be able to edit it.
>>> from canonical.launchpad.testing.pages import strip_label
>>> admin_browser.open(
... 'http://translations.launchpad.dev/+languages/es')
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/es
>>> admin_browser.getLink('Administer').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/es/+admin
>>> print admin_browser.getControl('ISO 639').value
es
>>> print admin_browser.getControl('English name').value
Spanish
>>> print admin_browser.getControl('Native name').value
>>> print admin_browser.getControl('Number of plural forms').value
2
>>> print admin_browser.getControl('Plural form expression').value
n != 1
>>> print admin_browser.getControl('Visible').optionValue
on
>>> print admin_browser.getControl('Text direction').displayValue
['Left to Right']
>>> control = admin_browser.getControl(name='field.countries')
>>> print [strip_label(country) for country in control.displayValue]
['Argentina', 'Bolivia', 'Chile', 'Colombia',
'Costa Rica', 'Dominican Republic', 'Ecuador',
'El Salvador', 'Guatemala', 'Honduras', 'Mexico',
'Nicaragua', 'Panama', 'Paraguay', 'Peru',
'Puerto Rico', 'Spain', 'United States', 'Uruguay',
'Venezuela']
Changing values and submitting the form will allow the admin to change
values.
If the new language code already exists, the system will show a failure
so the user can fix it.
>>> admin_browser.getControl('ISO 639').value = 'fr'
>>> admin_browser.getControl('Admin Language').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/es/+admin
>>> for tag in find_tags_by_class(admin_browser.contents, 'message'):
... print tag.renderContents()
There is 1 error.
There is already a language with that code.
Changing values to correct content works:
>>> admin_browser.getControl('ISO 639').value = 'bars'
>>> admin_browser.getControl('English name').value = 'Changed field'
>>> spokenin_control = admin_browser.getControl(name='field.countries')
>>> spokenin_control.getControl('Argentina').selected = False
>>> spokenin_control.getControl('France').selected = True
>>> admin_browser.getControl('Admin Language').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/bars
And we can validate it:
>>> admin_browser.getLink('Administer').click()
>>> print admin_browser.url
http://translations.launchpad.dev/+languages/bars/+admin
>>> print admin_browser.getControl('ISO 639').value
bars
>>> print admin_browser.getControl('English name').value
Changed field
>>> control = admin_browser.getControl(name='field.countries')
>>> print [strip_label(country) for country in control.displayValue]
['Bolivia', 'Chile', 'Colombia', 'Costa Rica',
'Dominican Republic', 'Ecuador', 'El Salvador', 'France',
'Guatemala', 'Honduras', 'Mexico', 'Nicaragua',
'Panama', 'Paraguay', 'Peru', 'Puerto Rico', 'Spain',
'United States', 'Uruguay', 'Venezuela']
That was a renaming action, which means that language code 'es' doesn't
exist anymore.
>>> browser.open('http://translations.launchpad.dev/+languages/es')
Traceback (most recent call last):
...
NotFound:...
|