Nice branch. I've got a couple of comments - just fixes needed in the doctest narrative - other than that this is fine. Please ping me when you've made the necessary changes and I'll EC2 it.
> +users which have configured their prefered language. Since KarmaCache tables
> +are generated using nightly builds, we will change Langauge.translators to
> +use the list of translators generated by this test.
> +
> + >>> from lp.services.worlddata.model.language import Language
> + >>> # Delete Language.translators so that we can add our custom
> + >>> # implementation later.
> + >>> del Language.translators
> >>> serbian = language_set.getLanguageByCode('sr')
> >>> language_view = create_initialized_view(serbian, '+index',
> ... layer=TranslationsLayer)
>
> -The friendlypluralforms function shows us a list of plural forms and
> +The 'friendly_plural_forms' 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.
>
> @@ -95,6 +104,55 @@
> 1 : 2, 3, 4, 22, 23, 24...
> 2 : 5, 6, 7, 8, 9, 10...
>
> +Top 20 contributors are listed on the language page, and for merged account
Hi Adi,
Nice branch. I've got a couple of comments - just fixes needed in the doctest narrative - other than that this is fine. Please ping me when you've made the necessary changes and I'll EC2 it.
> === modified file 'lib/lp/ translations/ browser/ language. py' translations/ browser/ language. py 2009-12-08 10:20:37 +0000 translations/ browser/ language. py 2010-03-02 11:04:22 +0000 rson) .browser. translations import TranslationsMixin .utilities. pluralforms import make_friendly_ plural_ forms launchpad. interfaces. launchpad import ILaunchpadCeleb rities ckBoxWidget ors(self) : translators[ :20] s(self) :
> --- lib/lp/
> +++ lib/lp/
> @@ -34,7 +34,6 @@
> ITranslationsPe
> from lp.translations
> from lp.translations
> -from canonical.
>
> from canonical.widgets import LabeledMultiChe
>
> @@ -214,8 +213,31 @@
> })
> return translation_teams
>
> - def getTopContribut
> - return self.context.
> + @property
> + def top_contributor
> + """
> + Get top 20 contributors for a language.
s/Get/Get the
> +
> + Instead of merged account, show the merged target account.
This would read better as: "If an account has been merged, the account
into which it was merged will be returned."
> + """ list(self. context. translators) ): append( translator_ target) plural_ forms(self) : translations/ browser/ tests/language- views.txt' translations/ browser/ tests/language- views.txt 2009-12-03 15:14:55 +0000 translations/ browser/ tests/language- views.txt 2010-03-02 11:04:22 +0000 worlddata. interfaces. language import ILanguageSet view(language_ set, '+add', onsLayer)
> + translators = []
> + for translator in reversed(
> + # Get only the top 20 contributors
> + if (len(translators) >= 20):
> + break
> +
> + # For merged account add the target account
> + if translator.merged != None:
> + translator_target = translator.merged
> + else:
> + translator_target = translator
> +
> + # Add translator only if it was not previouly added as a
> + # merged account
> + if translator_target not in translators:
> + translators.
> +
> + return translators
>
> @property
> def friendly_
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -1,8 +1,8 @@
> Language Views
> -==================
> +==============
>
> Admin Language
> -------------------
> +--------------
>
> >>> from zope.component import getUtility
> >>> from lp.services.
> @@ -34,7 +34,7 @@
>
>
> Add Language
> -------------------
> +------------
>
> >>> language_add_view = create_
> ... layer=Translati
> @@ -77,13 +77,22 @@
>
>
> View Language
> -------------------
> -
> +-------------
> +
> +Translators list for each language is computed using KarmaCache table for
s/list/lists ; s/is computed/are computed ; s/table/tables.
> +users which have configured their prefered language. Since KarmaCache tables translators to worlddata. model.language import Language translators so that we can add our custom translators set.getLanguage ByCode( 'sr') initialized_ view(serbian, '+index', onsLayer) plural_ forms' function shows us a list of plural forms and
> +are generated using nightly builds, we will change Langauge.
> +use the list of translators generated by this test.
> +
> + >>> from lp.services.
> + >>> # Delete Language.
> + >>> # implementation later.
> + >>> del Language.
> >>> serbian = language_
> >>> language_view = create_
> ... layer=Translati
>
> -The friendlypluralforms function shows us a list of plural forms and
> +The 'friendly_
> a set of examples for each one, so one won't need to understand the plural
> formula expression to see how it works.
>
> @@ -95,6 +104,55 @@
> 1 : 2, 3, 4, 22, 23, 24...
> 2 : 5, 6, 7, 8, 9, 10...
>
> +Top 20 contributors are listed on the language page, and for merged account
s/Top/The top/g
> +we will see their targed account. append( factory. makePerson( 'Translator No.' + str(translator_ nr))) r-main' , 'Translator Main') append( translator_ main) r-merged' , 'Translator Merged') append( translator_ merged) merged. merged = translator_main makeProduct( official_ rosetta= True) makePOTemplate( product. getSeries( 'trunk' )) makePOTMsgSet( template) makePOFile( 'sr', potemplate= template) makeTranslation Message( translator, potmsgset= potmsgset) makeTranslation Message( translator_ merged, potmsgset= potmsgset) makeTranslation Message( translator_ main, potmsgset= potmsgset) translators to avoid fetching KarmaCache initialized_ view(serbian, '+index', onsLayer) view.top_ contributors makePerson( ) translations/ stories/ standalone/ xx-pofile- details. txt' translations/ stories/ standalone/ xx-pofile- details. txt 2009-12-15 14:11:39 +0000 translations/ stories/ standalone/ xx-pofile- details. txt 2010-03-02 11:04:22 +0000 makePOFile( language_ code, potemplate= template) makePOTMsgSet( template) setSequence( template, 1) makeTranslation Message( pofile= pofile, merged_ translator, potmsgset= potmsgset) setSequence( template, 2) makeTranslation Message( pofile= pofile, translator, potmsgset= potmsgset) translator. merged = translator translations. launchpad. dev/" hoary/+ source/ %s/+pots/ %s/%s/+ details" ) % ( text(find_ main_content( browser. contents) ) text(find_ main_content( browser. contents) ) translations/ templates/ language- portlet- top-contributor s.pt' translations/ templates/ language- portlet- top-contributor s.pt 2009-08-28 15:40:27 +0000 translations/ templates/ language- portlet- top-contributor s.pt 2010-03-02 11:04:22 +0000 name>: "contributor view/getTopCont ributors" > "contributor view/top_ contributors" > "structure contributor/ fmt:link" >Guilherme Salgado</a> translations/ templates/ pofile- details. pt' translations/ templates/ pofile- details. pt 2010-01-20 22:31:50 +0000 translations/ templates/ pofile- details. pt 2010-03-02 11:04:22 +0000 "view/contribut ors"> "contributor view/contributors"> merged" > "structure contributor/ fmt:link" /> rs-loop repeat="contributor view/contributors"> merged" > "structure contributor/ fmt:link" > ${context/ fmt:url} /+filter? person= ${contributor/ name}" ors-loop>
> +
> +Create some translators and a merged account.
> + >>> translators = []
> + >>> for translator_nr in range(22):
> + ... translators.
> + ... name='translator-' + str(translator_nr),
> + ... displayname=
> + >>> translator_main = factory.makePerson(
> + ... name='translato
> + ... displayname=
> + >>> translators.
> + >>> translator_merged = factory.makePerson(
> + ... name='translato
> + ... displayname=
> + >>> translators.
> + >>> translator_
> +
> +Create a product, a template with one msgset and a pofile
> +
> + >>> product = factory.
> + >>> template = factory.
> + ... productseries=
> + >>> potmsgset = factory.
> + >>> pofile = factory.
> +
> +Add a translation for each translator and one more for main and merged
> +accounts.
> +
> + >>> for translator in translators:
> + ... translation = factory.
> + ... pofile=pofile, translator=
> + >>> translation = factory.
> + ... pofile=pofile, translator=
> + >>> translation = factory.
> + ... pofile=pofile, translator=
> +
> + >>> # Monkey-patch Langauge.
> + >>> serbian.translators = translators
> + >>> language_view = create_
> + ... layer=Translati
> + >>> top_contributors = language_
> + >>> translator_main in top_contributors
> + True
> + >>> translator_merged in top_contributors
> + False
> +
> +
> View LanguageSet
> ------------------
>
> @@ -110,7 +168,7 @@
> <a href=".../en" ...>English</a>,
> <a href=".../es" ...>Spanish</a>
>
> -For a user without any preferred languages, English will be returned.
> +For a user without any preferred languages, English will be returned.
>
> >>> person = factory.
> >>> print person.languages
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -151,10 +151,8 @@
> >>> language_code = 'es'
> >>> pofile = factory.
> >>> potmsgset = factory.
> - >>> potmsgset.
> >>> translation = factory.
> ... translator=
> - >>> potmsgset.
> >>> translation = factory.
> ... translator=
> >>> merged_
> @@ -164,10 +162,13 @@
> ... ("http://
> ... "ubuntu/
> ... package.name, template.name, language_code))
> - >>> print extract_
> + >>> main_text = extract_
> + >>> print main_text
> Details for ...
> Contributors to this translation
> The following people have made some contribution to this specific
> translation:
> Poly Glot (filter)
>
> + >>> u'Mere Pere' in main_text
> + False
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -14,7 +14,7 @@
> </tal:language_
> </p>
> <ul>
> - <li tal:repeat=
> + <li tal:repeat=
> <a tal:replace=
> </li>
> </ul>
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -41,14 +41,16 @@
> </p>
>
> <ul tal:condition=
> - <li tal:repeat=
> - <tal:not-merged condition="not: contributor/
> - <a tal:replace=
> + <tal:contributo
> + <li tal:condition="not: contributor/
> + <a tal:replace=
> + Mister Potato
> + </a>
> (<a tal:attributes="
> href string:
> >filter</a>)
> - </tal:not-merged>
> </li>
> + </tal:contribut
> </ul>
>
> <p
>