Merge lp://staging/~danilo/launchpad/remaining-templates into lp://staging/launchpad

Proposed by Данило Шеган
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~danilo/launchpad/remaining-templates
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~danilo/launchpad/remaining-templates
Reviewer Review Type Date Requested Status
Gavin Panella (community) code Approve
Review via email: mp+11841@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

= Bug #430450 =

Migrate object-templates.pt and languagesets-index.pt to 3.0 layout:
simple mechanical changes.

Drive-by changes for plural forms rendering on language-index.pt page
(along with a test update).

= Demo & QA =

https://translations.launchpad.dev/+languages
https://translations.launchpad.dev/evolution/trunk/+templates
https://translations.launchpad.dev/ubuntu/hoary/+templates

and for drive by cleanup

https://translations.launchpad.dev/+languages/sr

= Tests =

bin/test -vvt xx-language -t stories.*templates -t pluralforms

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/translations/browser/language.py
  lib/lp/translations/stories/standalone/xx-language.txt
  lib/lp/translations/templates/languageset-index.pt
  lib/lp/translations/templates/object-templates.pt
  lib/lp/translations/utilities/pluralforms.py
  lib/lp/translations/utilities/doc/pluralforms.txt

Revision history for this message
Gavin Panella (allenap) wrote :
Download full text (15.6 KiB)

Hi Danilo,

Just a couple of minor comments.

Gavin.

> === modified file 'lib/lp/translations/browser/language.py'
> --- lib/lp/translations/browser/language.py 2009-09-10 13:31:25 +0000
> +++ lib/lp/translations/browser/language.py 2009-09-16 13:02:09 +0000
> @@ -170,7 +170,7 @@
> for item in pluralforms_list:
> examples = ", ".join(map(str, item['examples']))
> if len(item['examples']) != 1:
> - examples += ", ..."
> + examples += "..."
> else:
> examples += "."
> item['examples'] = examples
>
> === modified file 'lib/lp/translations/browser/tests/language-views.txt'
> --- lib/lp/translations/browser/tests/language-views.txt 2009-09-14 14:55:01 +0000
> +++ lib/lp/translations/browser/tests/language-views.txt 2009-09-16 13:02:09 +0000
> @@ -22,8 +22,9 @@
> >>> print language_admin_view.page_title
> Edit Portuguese (Brazil) (pt_BR)
>
> -The view provides also a cancel_url and a next_url, but they're the same because
> -the previous and next steps of editing a language are returning to its index.
> +The view provides also a cancel_url and a next_url, but they're the same
> +because the previous and next steps of editing a language are returning
> +to its index.
>
> >>> print language_admin_view.cancel_url
> http://translations.launchpad.dev/+languages/pt_BR
> @@ -35,7 +36,7 @@
> Add Language
> ------------------
>
> - >>> language_add_view = create_view(language_set, '+add',
> + >>> language_add_view = create_view(language_set, '+add',
> ... layer=TranslationsLayer)
>
> >>> print language_add_view.label
> @@ -50,7 +51,8 @@
> http://translations.launchpad.dev/+languages
>
> >>> print language_add_view.field_names
> - ['code', 'englishname', 'nativename', 'pluralforms', 'pluralexpression', 'visible', 'direction']
> + ['code', 'englishname', 'nativename', 'pluralforms',
> + 'pluralexpression', 'visible', 'direction']
>
> >>> login("<email address hidden>")
> >>> form = {
> @@ -81,15 +83,16 @@
> >>> language_view = create_initialized_view(serbian, '+index',
> ... layer=TranslationsLayer)
>
> -The friendlypluralforms function shows us a list of plural forms and a set of examples
> -for each one, so one won't need to understand the plural formula expression to see how it works.
> +The friendlypluralforms function shows us a list of plural forms and
> +a set of examples for each one, so one won't need to understand the plural
> +formula expression to see how it works.
>
> >>> friendly_plural_forms = language_view.friendly_plural_forms
>
> >>> for form_dict in friendly_plural_forms:
> ... print form_dict['form'], ':', form_dict['examples']
> - 0 : 1.
> - 1 : 2, 3, 4, ...
> - 2 : 5, 6, 7, 8, 9, 10, ...
> + 0 : 1, 21, 31, 41, 51, 61...
> + 1 : 2, 3, 4, 22, 23, 24...
> + 2 : 5, 6, 7, 8, 9, 10...
>
>
>
> === modified file 'lib/lp/translations/stories/standalone/xx-language.txt'
> --- lib/lp/translations/stories/standalone/xx-language.txt 2009-09-14 15:18:41 +0000
> +++ lib/lp/translations/stories/standalone/xx-language.txt 2009-09...

review: Approve (code)
Revision history for this message
Данило Шеган (danilo) wrote :

Heya, thanks again for the review.

У сре, 16. 09 2009. у 13:35 +0000, Gavin Panella пише:
>
> > === modified file 'lib/lp/translations/templates/languageset-index.pt'
> > --- lib/lp/translations/templates/languageset-index.pt 2009-07-17 17:59:07 +0000
> > +++ lib/lp/translations/templates/languageset-index.pt 2009-09-16 13:02:09 +0000
...
> > + <div class="yui-b top-portlet">
> > + <p>
> > + Languages registered in Launchpad can be used for per-language
> > + support with <a href="https://answers.launchpad.net">Answers</a>,
>
> Argh, there has to be a better way to do this than hard-coding the
> link. Maybe not now, but we should have something like this.
>
> Off the top of my head, I imagine a global for doing traversals. Then
> we could do things like:
>
> find/answers/fmt:link
>
> find/translations/fmt:link
>
> find/answers/rosetta/+faq/23/fmt:link
>
> And so on.

I thought about this myself. However, the best I could come up with
would be dependent on sampledata having this FAQ (at least the number)
as well, and that sounded icky.

> Maybe this is already possible in a different way.

Well, I considered something like view methods providing a canonical_url
to the FAQ. I could have definitely used that for
canonical_url(AnswersApplication) or similar, if that works.

> Also, this is totally out of scope for this branch. Still, I'm
> interested if you know a way to avoid hard-coding those URLs.

Not really. The way we usually did that was to introduce a celebrity
for something, and then canonical_url that. I don't want to introduce a
celebrity for the FAQ entry. Perhaps we should have an editable
text_to_html snippet on the page where we could say something like FAQ
#23
and it would be automatically linkified (like bugs already are in
text-to-html formatter).

> > + <div tal:condition="context/required:launchpad.Admin">
> > + <a href="+add" class="add sprite">Add new language</a>
>
> Could you use tal:attributes="href context/fmt:url/+add" here instead?

Certainly, done.

> > + <dl condition="view/search_matches" class="languages">
> > + <tal:language repeat="language results">
> > + <dt>
> > + <a tal:replace="structure language/fmt:link">
> > + Serbian (sr)
> > + </a>
> > + </dt>
> > + <dd></dd>
>
> Any reason to not use a <ul> here, as there is nothing in the <dd>?

Not really, changed.

Incremental diff attached.

Cheers,
Danilo

=== modified file 'lib/lp/translations/templates/languageset-index.pt'
--- lib/lp/translations/templates/languageset-index.pt 2009-09-16 03:56:44 +0000
+++ lib/lp/translations/templates/languageset-index.pt 2009-09-16 14:30:57 +0000
@@ -43,7 +43,8 @@
43 </p>43 </p>
44 </form>44 </form>
45 <div tal:condition="context/required:launchpad.Admin">45 <div tal:condition="context/required:launchpad.Admin">
46 <a href="+add" class="add sprite">Add new language</a>46 <a tal:attributes="href context/fmt:url/+add"
47 class="add sprite">Add new language</a>
47 </div>48 </div>
48 </div>49 </div>
49 </div>50 </div>
@@ -66,16 +67,15 @@
66 matching languages67 matching languages
67 </h2>68 </h2>
68 </tal:more>69 </tal:more>
69 <dl condition="view/search_matches" class="languages">70 <ul condition="view/search_matches" class="languages">
70 <tal:language repeat="language results">71 <tal:language repeat="language results">
71 <dt>72 <li>
72 <a tal:replace="structure language/fmt:link">73 <a tal:replace="structure language/fmt:link">
73 Serbian (sr)74 Serbian (sr)
74 </a>75 </a>
75 </dt>76 </li>
76 <dd></dd>
77 </tal:language>77 </tal:language>
78 </dl>78 </ul>
79 </tal:block>79 </tal:block>
80 </div>80 </div>
81 </div>81 </div>
8282

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/translations/browser/language.py'
--- lib/lp/translations/browser/language.py 2009-09-10 13:31:25 +0000
+++ lib/lp/translations/browser/language.py 2009-09-16 02:35:32 +0000
@@ -170,7 +170,7 @@
170 for item in pluralforms_list:170 for item in pluralforms_list:
171 examples = ", ".join(map(str, item['examples']))171 examples = ", ".join(map(str, item['examples']))
172 if len(item['examples']) != 1:172 if len(item['examples']) != 1:
173 examples += ", ..."173 examples += "..."
174 else:174 else:
175 examples += "."175 examples += "."
176 item['examples'] = examples176 item['examples'] = examples
177177
=== modified file 'lib/lp/translations/stories/standalone/xx-language.txt'
--- lib/lp/translations/stories/standalone/xx-language.txt 2009-09-14 15:18:41 +0000
+++ lib/lp/translations/stories/standalone/xx-language.txt 2009-09-16 02:35:32 +0000
@@ -13,7 +13,7 @@
1313
14Following the link, there is a form to add new languages.14Following the link, there is a form to add new languages.
1515
16 >>> admin_browser.getLink('Add Language').click()16 >>> admin_browser.getLink('Add new language').click()
17 >>> print admin_browser.url17 >>> print admin_browser.url
18 http://translations.launchpad.dev/+languages/+add18 http://translations.launchpad.dev/+languages/+add
1919
@@ -60,7 +60,7 @@
60 >>> print user_browser.url60 >>> print user_browser.url
61 http://translations.launchpad.dev/+languages61 http://translations.launchpad.dev/+languages
6262
63 >>> user_browser.getLink('Add Language')63 >>> user_browser.getLink('Add new language')
64 Traceback (most recent call last):64 Traceback (most recent call last):
65 ...65 ...
66 LinkNotFoundError66 LinkNotFoundError
@@ -78,14 +78,14 @@
7878
79 >>> text_search = browser.getControl(name='language_search')79 >>> text_search = browser.getControl(name='language_search')
80 >>> text_search.value = 'Spanish'80 >>> text_search.value = 'Spanish'
81 >>> browser.getControl('Search', index=0).click()81 >>> browser.getControl('Find language', index=0).click()
82 >>> print browser.url82 >>> print browser.url
83 http://translations.launchpad.dev/+languages/+index83 http://translations.launchpad.dev/+languages/+index
8484
85And following one of the found languages, we can see a brief information85And following one of the found languages, we can see a brief information
86about the selected language.86about the selected language.
8787
88 >>> browser.getLink('Spanish (es)').click()88 >>> browser.getLink('Spanish').click()
89 >>> print browser.url89 >>> print browser.url
90 http://translations.launchpad.dev/+languages/es90 http://translations.launchpad.dev/+languages/es
9191
@@ -94,10 +94,9 @@
94 Plural forms94 Plural forms
95 Spanish has 2 plural forms:95 Spanish has 2 plural forms:
96 Form 0 for 1.96 Form 0 for 1.
97 Form 1 for 2, 3, 4, 5, 6, 7, ...97 Form 1 for 2, 3, 4, 5, 6, 7...
98 When ...98 When ...
9999
100
101 >>> translationteams_portlet = find_portlet(100 >>> translationteams_portlet = find_portlet(
102 ... browser.contents, 'Translation teams')101 ... browser.contents, 'Translation teams')
103 >>> print translationteams_portlet102 >>> print translationteams_portlet
104103
=== modified file 'lib/lp/translations/templates/languageset-index.pt'
--- lib/lp/translations/templates/languageset-index.pt 2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/languageset-index.pt 2009-09-16 02:35:32 +0000
@@ -3,97 +3,79 @@
3 xmlns:tal="http://xml.zope.org/namespaces/tal"3 xmlns:tal="http://xml.zope.org/namespaces/tal"
4 xmlns:metal="http://xml.zope.org/namespaces/metal"4 xmlns:metal="http://xml.zope.org/namespaces/metal"
5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
6 xml:lang="en"6 metal:use-macro="view/macro:page/main_only"
7 lang="en"
8 dir="ltr"
9 metal:use-macro="context/@@main_template/master"
10 i18n:domain="launchpad"
11>7>
128
13 <body>9 <body>
14 <metal:portlets fill-slot="portlets">
15 </metal:portlets>
16
17 <div metal:fill-slot="main">10 <div metal:fill-slot="main">
18 <h1>Languages in Launchpad</h1>11 <h1>Languages in Launchpad</h1>
19 <form method="post">12 <div class="yui-b top-portlet">
20 <table>13 <p>
21 <tr>14 Languages registered in Launchpad can be used for per-language
22 <th>15 support with <a href="https://answers.launchpad.net">Answers</a>,
16 or for
17 <a href="https://translations.launchpad.net">Translations</a>.
18 <p>
19 <p>
20 If you can't find a language you are interested in, and you want
21 to add it to Launchpad for either Answers or Translations, please
22 follow
23 <a href="https://answers.launchpad.net/rosetta/+faq/23">
24 How to create a new language
25 </a>
26 FAQ entry.
27 </p>
28
29 <div class="portlet">
30 <h2>Find a language in Launchpad</h2>
31 <form method="post">
32 <p>
23 <label for="language_search">33 <label for="language_search">
24 Search Languages in Launchpad:34 Language name/code contains:
25 </label>35 </label>
26 </th>36 <input
27 <td>37 name="language_search" size="30"
28 <input38 tal:attributes="value view/language_search" />
29 name="language_search" size="30"39 <input
30 tal:attributes="value view/language_search" />40 type="submit"
31 </td>41 value="Find language"
32 </tr>42 />
33 <tr>43 </p>
34 <td></td>44 </form>
35 <td>45 <div tal:condition="context/required:launchpad.Admin">
36 <div class="actions">46 <a href="+add" class="add sprite">Add new language</a>
37 <input47 </div>
38 tal:condition="view/search_requested"48 </div>
39 type="submit"49 </div>
40 value="Search Again"50 <div tal:condition="view/search_requested" class="yui-b portlet">
41 />
42 <input
43 tal:condition="not: view/search_requested"
44 type="submit"
45 value="Search Languages"
46 />
47 </div>
48 </td>
49 </tr>
50 </table>
51 </form>
52 <div tal:condition="view/search_requested">
53 <tal:block tal:define="results view/search_results">51 <tal:block tal:define="results view/search_results">
54 <table class="listing">52 <tal:none condition="not: view/search_matches">
55 <thead>53 <h2>No matching languages</h2>
56 <tr class="results">54 <p>No languages matching
57 <td colspan="0">55 &#8220;<span tal:replace="view/language_search">
58 <span tal:replace="view/search_matches">3</span>56 Foo
59 <span tal:condition="python: view.search_matches == 1">57 </span>&#8221; were found.
60 result58 </p>
61 </span>59 </tal:none>
62 <span tal:condition="python: view.search_matches != 1">60 <tal:one condition="python: view.search_matches == 1">
63 results61 <h2>One matching language</h2>
64 </span>62 </tal:one>
65 </td>63 <tal:more condition="python: view.search_matches > 1">
66 </tr>64 <h2>
67 </thead>65 <tal:count replace="view/search_matches">3</tal:count>
68 <tbody>66 matching languages
69 <tr>67 </h2>
70 <td>68 </tal:more>
71 <dl condition="view/search_matches" class="languages">69 <dl condition="view/search_matches" class="languages">
72 <tal:block repeat="language results">70 <tal:language repeat="language results">
73 <dt>71 <dt>
74 <a tal:attributes="href language/code">72 <a tal:replace="structure language/fmt:link">
75 <dfn tal:content="language/englishname">73 Serbian (sr)
76 $Language.englishname74 </a>
77 </dfn>75 </dt>
78 (<span tal:replace="language/code">76 <dd></dd>
79 $Language.code77 </tal:language>
80 </span>)78 </dl>
81 </a>
82 </dt>
83 <dd>
84 </dd>
85 </tal:block>
86 </dl>
87 <p tal:condition="not: view/search_matches">
88 <strong>No Languages matching &#8220;
89 <span tal:replace="view/language_search">Foo</span>&#8221;
90 were found.
91 </strong>
92 </p>
93 </td>
94 </tr>
95 </tbody>
96 </table>
97 </tal:block>79 </tal:block>
98 </div>80 </div>
99 </div>81 </div>
10082
=== modified file 'lib/lp/translations/templates/object-templates.pt'
--- lib/lp/translations/templates/object-templates.pt 2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/object-templates.pt 2009-09-16 02:35:32 +0000
@@ -2,16 +2,8 @@
2 xmlns="http://www.w3.org/1999/xhtml"2 xmlns="http://www.w3.org/1999/xhtml"
3 xmlns:tal="http://xml.zope.org/namespaces/tal"3 xmlns:tal="http://xml.zope.org/namespaces/tal"
4 xmlns:metal="http://xml.zope.org/namespaces/metal"4 xmlns:metal="http://xml.zope.org/namespaces/metal"
5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"5 metal:use-macro="view/macro:page/main_only"
6 xml:lang="en"6>
7 lang="en"
8 dir="ltr"
9 metal:use-macro="view/macro:page/onecolumn"
10 i18n:domain="launchpad"
11><!-- context/@@main_template/master
12 view/macro:page/onecolumn
13 -->
14
15 <body>7 <body>
16 <div metal:fill-slot="head_epilogue">8 <div metal:fill-slot="head_epilogue">
17 <style type="text/css">9 <style type="text/css">
@@ -61,13 +53,6 @@
61 </script>53 </script>
62 </div>54 </div>
63 <div metal:fill-slot="main">55 <div metal:fill-slot="main">
64 <h1>
65 Translation templates for
66 <tal:title replace="context/title">
67 evolution in Ubuntu Feisty
68 </tal:title>
69 </h1>
70
71 <ul class="helplinks">56 <ul class="helplinks">
72 <li>57 <li>
73 <a href="https://help.launchpad.net/Translations"58 <a href="https://help.launchpad.net/Translations"
@@ -77,6 +62,21 @@
77 </li>62 </li>
78 </ul>63 </ul>
7964
65 <h1>
66 Translation templates for
67 <tal:title replace="context/title">
68 evolution in Ubuntu Feisty
69 </tal:title>
70 </h1>
71
72 <div class="yui-b top-portlet">
73 <p>
74 This is a listing of all the translatable templates
75 in <a tal:replace="structure context/fmt:link">here</a>.
76 </p>
77 </div>
78
79 <div class="yui-b">
80 <table class="sortable listing" id="templates_table">80 <table class="sortable listing" id="templates_table">
81 <thead>81 <thead>
82 <tr>82 <tr>
@@ -114,6 +114,7 @@
114 </tr>114 </tr>
115 </tbody>115 </tbody>
116 </table>116 </table>
117 </div>
117 </div>118 </div>
118 </body>119 </body>
119</html>120</html>
120121
=== modified file 'lib/lp/translations/utilities/doc/pluralforms.txt'
--- lib/lp/translations/utilities/doc/pluralforms.txt 2009-09-14 14:55:01 +0000
+++ lib/lp/translations/utilities/doc/pluralforms.txt 2009-09-16 02:35:32 +0000
@@ -7,20 +7,20 @@
7make_friendly_plural_forms7make_friendly_plural_forms
8--------------------------8--------------------------
99
10The make_friendly_plural_forms method creates a list of dicts, each one containing a 10The make_friendly_plural_forms method creates a list of dicts, each one
11plural form number and a list of examples for this plural form.11containing a plural form number and a list of examples for this plural form.
12It uses as input the plural forms expression for the language, C-like, and the number 12It uses as input the plural forms expression for the language, C-like, and
13of plural forms for the considered language.13the number of plural forms for the considered language.
1414
15 >>> from lp.translations.utilities.pluralforms import (15 >>> from lp.translations.utilities.pluralforms import (
16 ... make_friendly_plural_forms)16 ... make_friendly_plural_forms)
1717
1818Let's use a Serbian language as example. Here's the plural forms
19Let's use the serbian language as example. Here's the plural forms expression for serbian:19expression for Serbian:
2020
21 >>> expression = 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'21 >>> expression = 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'
2222
23It's also known that serbian has 3 plural forms.23It's also known that Serbian has 3 plural forms.
2424
25 >>> pluralforms_count = 325 >>> pluralforms_count = 3
2626
@@ -29,6 +29,6 @@
2929
30 >>> for form_dict in friendly_plural_forms:30 >>> for form_dict in friendly_plural_forms:
31 ... print form_dict['form'], ":", form_dict['examples']31 ... print form_dict['form'], ":", form_dict['examples']
32 0 : [1]32 0 : [1, 21, 31, 41, 51, 61]
33 1 : [2, 3, 4]33 1 : [2, 3, 4, 22, 23, 24]
34 2 : [5, 6, 7, 8, 9, 10]34 2 : [5, 6, 7, 8, 9, 10]
3535
=== modified file 'lib/lp/translations/utilities/pluralforms.py'
--- lib/lp/translations/utilities/pluralforms.py 2009-09-11 03:06:13 +0000
+++ lib/lp/translations/utilities/pluralforms.py 2009-09-16 02:35:32 +0000
@@ -25,9 +25,6 @@
25 forms.setdefault(form, [])25 forms.setdefault(form, [])
26 # If all the plural forms for this language have examples (max. of 626 # If all the plural forms for this language have examples (max. of 6
27 # numbers per plural form), it stops.27 # numbers per plural form), it stops.
28 if (len(forms[form]) == MAX_EXAMPLES and
29 len(forms) == pluralforms_count):
30 break
31 if len(forms[form]) == MAX_EXAMPLES:28 if len(forms[form]) == MAX_EXAMPLES:
32 continue29 continue
33 forms[form].append(number)30 forms[form].append(number)
3431