r634 - in zope-plonelanguagetool/branches/upstream/current: . tests
Fabio Tranchitella
kobold at alioth.debian.org
Fri Feb 9 14:56:33 CET 2007
Author: kobold
Date: 2007-02-09 14:56:33 +0100 (Fri, 09 Feb 2007)
New Revision: 634
Added:
zope-plonelanguagetool/branches/upstream/current/tests/test_negotiation.py
Removed:
zope-plonelanguagetool/branches/upstream/current/tests/testSkeleton.py
Modified:
zope-plonelanguagetool/branches/upstream/current/HISTORY.txt
zope-plonelanguagetool/branches/upstream/current/LanguageTool.py
zope-plonelanguagetool/branches/upstream/current/availablelanguages.py
zope-plonelanguagetool/branches/upstream/current/version.txt
Log:
[svn-upgrade] Integrating new upstream version, zope-plonelanguagetool (1.5)
Modified: zope-plonelanguagetool/branches/upstream/current/HISTORY.txt
===================================================================
--- zope-plonelanguagetool/branches/upstream/current/HISTORY.txt 2007-02-09 13:55:19 UTC (rev 633)
+++ zope-plonelanguagetool/branches/upstream/current/HISTORY.txt 2007-02-09 13:56:33 UTC (rev 634)
@@ -2,6 +2,24 @@
(name of developer listed in brackets)
+PloneLanguageTool 1.5 - Released December 15, 2006
+
+ - Fixed bug in request language negotiation. If the tool is configured not
+ to use combined language codes, we have to use the basic language code in
+ all places. This closes http://dev.plone.org/plone/ticket/5804 and
+ http://dev.plone.org/plone/ticket/5941.
+ [hannosch]
+
+ - Added missing Chamorro language to the basic listing.
+ This closes http://dev.plone.org/plone/ticket/5836.
+ [hannosch]
+
+ - Removed obsolete testSkeleton.
+ [hannosch]
+
+ - Changed the native Name of 'rm' to 'Rumantsch'.
+ [jensens]
+
PloneLanguageTool 1.4 - Released September 8, 2006
- Changed the browser language based negotiation to recognize combined
Modified: zope-plonelanguagetool/branches/upstream/current/LanguageTool.py
===================================================================
--- zope-plonelanguagetool/branches/upstream/current/LanguageTool.py 2007-02-09 13:55:19 UTC (rev 633)
+++ zope-plonelanguagetool/branches/upstream/current/LanguageTool.py 2007-02-09 13:56:33 UTC (rev 634)
@@ -320,6 +320,10 @@
"""Gets the preferred site language."""
l = self.getLanguageBindings()
if l[0]:
+ if not self.use_combined_language_codes:
+ return l[0].split('-')[0]
+ else:
+ return l[0]
return l[0]
# this is the default language
return l[1]
@@ -399,8 +403,9 @@
# if we only use simply language codes, we should recognize
# combined codes as their base code. So 'de-de' is treated
# as 'de'.
- if language.split('-')[0] in self.getSupportedLanguages():
- langs.append((quality, language))
+ baselanguage = language.split('-')[0]
+ if baselanguage in self.getSupportedLanguages():
+ langs.append((quality, baselanguage))
i = i + 1
# Sort and reverse it
Modified: zope-plonelanguagetool/branches/upstream/current/availablelanguages.py
===================================================================
--- zope-plonelanguagetool/branches/upstream/current/availablelanguages.py 2007-02-09 13:55:19 UTC (rev 633)
+++ zope-plonelanguagetool/branches/upstream/current/availablelanguages.py 2007-02-09 13:56:33 UTC (rev 634)
@@ -48,6 +48,10 @@
# This is a dictionary of dictonaries:
#
# 'langcode-variation' : {native : 'Native name', english : 'English name', flag : 'flag-*.gif'}
+#
+# The current structure is to have language codes following ISO639-1 and to
+# have flags which are named according to country codes following ISO3166-1.
+#
languages = {
'aa' : {'native' : 'магIарул мацI', 'english' : 'Afar', 'flag' : 'flag-dj.gif'},
@@ -62,12 +66,13 @@
'be' : {'native' : 'Беларускі', 'english' : 'Belarussian', 'flag' : 'flag-by.gif'},
'bg' : {'native' : 'Български', 'english' : 'Bulgarian', 'flag' : 'flag-bg.gif'},
'bh' : {'native' : 'Bihari', 'english' : 'Bihari'},
-'bi' : {'native' : 'Bislama', 'english' : 'Bislama'},
+'bi' : {'native' : 'Bislama', 'english' : 'Bislama', 'flag' : 'flag-vu.gif'},
'bn' : {'native' : 'বাংলা', 'english' : 'Bengali'},
'bo' : {'native' : 'བོད་སྐད་', 'english' : 'Tibetan'},
'bs' : {'native' : 'Bosanski', 'english' : 'Bosnian', 'flag' : 'flag-ba.gif'},
'br' : {'native' : 'Brezhoneg', 'english' : 'Breton'},
'ca' : {'native' : 'Català', 'english' : 'Catalan', 'flag' : 'flag-cat.gif'},
+'ch' : {'native' : 'Chamoru', 'english' : 'Chamorro'},
'co' : {'native' : 'Corsu', 'english' : 'Corsican'},
'cs' : {'native' : 'Čeština', 'english' : 'Czech', 'flag' : 'flag-cz.gif'},
'cy' : {'native' : 'Cymraeg', 'english' : 'Welsh', 'flag' : 'flag-cym.gif'},
@@ -148,7 +153,7 @@
'ps' : {'native' : 'پښتو', 'english' : 'Pashto'},
'pt' : {'native' : 'Português', 'english' : 'Portuguese', 'flag' : 'flag-pt.gif'},
'qu' : {'native' : 'Quechua', 'english' : 'Quechua'},
-'rm' : {'native' : 'Rhaeto-Romance', 'english' : ''},
+'rm' : {'native' : 'Rumantsch', 'english' : 'Rhaeto-Romance'},
'rn' : {'native' : 'Kirundi', 'english' : 'Kirundi'},
'ro' : {'native' : 'Română', 'english' : 'Romanian', 'flag' : 'flag-ro.gif'},
'ru' : {'native' : 'Русский', 'english' : 'Russian', 'flag' : 'flag-ru.gif'},
Deleted: zope-plonelanguagetool/branches/upstream/current/tests/testSkeleton.py
===================================================================
--- zope-plonelanguagetool/branches/upstream/current/tests/testSkeleton.py 2007-02-09 13:55:19 UTC (rev 633)
+++ zope-plonelanguagetool/branches/upstream/current/tests/testSkeleton.py 2007-02-09 13:56:33 UTC (rev 634)
@@ -1,25 +0,0 @@
-#
-# PloneLanguageTool TestCase
-#
-
-import os, sys
-if __name__ == '__main__':
- execfile(os.path.join(sys.path[0], 'framework.py'))
-
-from Testing import ZopeTestCase
-
-ZopeTestCase.installProduct('PloneLanguageTool')
-
-class TestSomething(ZopeTestCase.ZopeTestCase):
-
- def afterSetUp(self):
- pass
-
-def test_suite():
- from unittest import TestSuite, makeSuite
- suite = TestSuite()
- suite.addTest(makeSuite(TestSomething))
- return suite
-
-if __name__ == '__main__':
- framework()
Added: zope-plonelanguagetool/branches/upstream/current/tests/test_negotiation.py
===================================================================
--- zope-plonelanguagetool/branches/upstream/current/tests/test_negotiation.py 2007-02-09 13:55:19 UTC (rev 633)
+++ zope-plonelanguagetool/branches/upstream/current/tests/test_negotiation.py 2007-02-09 13:56:33 UTC (rev 634)
@@ -0,0 +1,121 @@
+import os, sys
+if __name__ == '__main__':
+ execfile(os.path.join(sys.path[0], 'framework.py'))
+
+from Products.PloneTestCase import PloneTestCase
+from Products.PloneTestCase.PloneTestCase import default_user
+from Products.PloneTestCase.PloneTestCase import default_password
+
+PloneTestCase.installProduct('PloneLanguageTool')
+
+PloneTestCase.setupPloneSite(products=['PloneLanguageTool'])
+from Products.PloneLanguageTool import LanguageTool
+
+
+class LanguageNegotiationTestCase(PloneTestCase.FunctionalTestCase):
+
+ def afterSetUp(self):
+ self.basic_auth = '%s:%s' % (default_user, default_password)
+ self.portal_path = self.portal.absolute_url(1)
+ self.tool = self.portal[LanguageTool.id]
+
+
+class TestDefaultLanguageNegotiation(LanguageNegotiationTestCase):
+
+ def testLanguageNegotiation(self):
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'pt'})
+
+ self.assertEquals(response.getStatus(), 200)
+ # Once PLT is installed only English is allowed as a language
+ self.assertEquals(response.headers['content-language'], 'en')
+
+
+class TestNoCombinedLanguageNegotiation(LanguageNegotiationTestCase):
+
+ def afterSetUp(self):
+ LanguageNegotiationTestCase.afterSetUp(self)
+ # set some allowed languages and make sure we don't use combined
+ # language codes
+ self.tool.supported_langs = ['en', 'pt', 'de']
+ self.tool.use_combined_language_codes = 0
+ self.tool.display_flags = 0
+
+ def testLanguageNegotiation(self):
+ # Test simple supported codes
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'pt'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="pt">'
+ in response.getBody())
+
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'de'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="de">'
+ in response.getBody())
+
+ # Test combined unsupported codes, should fall back
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'pt-br'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="pt">'
+ in response.getBody())
+
+
+class TestCombinedLanguageNegotiation(LanguageNegotiationTestCase):
+
+ def afterSetUp(self):
+ LanguageNegotiationTestCase.afterSetUp(self)
+ # set some allowed languages and make sure we don't use combined
+ # language codes
+ self.tool.supported_langs = ['en', 'pt', 'de', 'pt-br']
+ self.tool.use_combined_language_codes = 1
+ self.tool.display_flags = 0
+
+ def testLanguageNegotiation(self):
+ # Test simple supported codes
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'pt'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="pt">'
+ in response.getBody())
+
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'de'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="de">'
+ in response.getBody())
+
+ # Test combined supported codes
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'pt-br'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="pt-br">'
+ in response.getBody())
+
+ # Test combined unsupported codes, should fall back
+ response = self.publish(self.portal_path, self.basic_auth,
+ env={'HTTP_ACCEPT_LANGUAGE': 'de-de'})
+
+ self.assertEquals(response.getStatus(), 200)
+ self.failUnless('<option selected="selected" value="de">'
+ in response.getBody())
+
+
+def test_suite():
+ from unittest import TestSuite, makeSuite
+ suite = TestSuite()
+ suite.addTest(makeSuite(TestDefaultLanguageNegotiation))
+ suite.addTest(makeSuite(TestNoCombinedLanguageNegotiation))
+ return suite
+
+if __name__ == '__main__':
+ framework()
+
Modified: zope-plonelanguagetool/branches/upstream/current/version.txt
===================================================================
--- zope-plonelanguagetool/branches/upstream/current/version.txt 2007-02-09 13:55:19 UTC (rev 633)
+++ zope-plonelanguagetool/branches/upstream/current/version.txt 2007-02-09 13:56:33 UTC (rev 634)
@@ -1 +1 @@
-1.4
+1.5
More information about the pkg-zope-commits
mailing list