- Timestamp:
- 25 Feb 2012, 06:53:45 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r7694 r7701 18 18 import grok 19 19 from urllib import urlencode 20 from zope.component import getMultiAdapter, queryAdapter 20 from zope.component import getMultiAdapter, queryAdapter, getUtility 21 21 from zope.interface import Interface 22 22 from zope.location.interfaces import ISite … … 29 29 IFacultiesContainer, IFaculty, IDepartment, ICourse, ICertificate, 30 30 ICertificateCourse, IBreadcrumbContainer, IUniversity, IUsersContainer) 31 from waeup.sirp.interfaces import (ISIRPObject, ISIRPXMLExporter, 32 ISIRPXMLImporter, IDataCenter, IUserAccount) 31 from waeup.sirp.interfaces import ( 32 ISIRPUtils, ISIRPObject, ISIRPXMLExporter, 33 ISIRPXMLImporter, IDataCenter, IUserAccount) 33 34 from waeup.sirp.browser.layout import SIRPPage, default_primary_nav_template 34 35 from waeup.sirp.utils.helpers import get_user_account … … 207 208 ) 208 209 209 class LanguageLink(grok.Viewlet): 210 """ An entry in the language selector. 211 212 This is only a baseclass that won't be rendered actually. Deriving 213 viewlets can override certain values and will be rendered with the 214 values set here as default. 215 """ 216 grok.baseclass() 210 class LanguagesLink(grok.Viewlet): 211 """ The language selector itself. 212 """ 217 213 grok.viewletmanager(LanguageManager) 218 214 grok.context(ISIRPObject) 219 215 grok.require('waeup.Public') 220 lang = 'de' 221 title = u'Deutsch' 216 title = u'Languages' 222 217 223 218 def render(self): 224 args = {'lang':self.lang, 'view_name':self.view.__name__} 225 url = self.view.url( 226 self.context) + '/@@change_language?%s' % urlencode(args) 227 return u'| <a href="%s" title="%s">%s</a> ' % (url,self.title,self.lang) 228 229 class English(LanguageLink): 230 """A link to switch to English. 231 """ 232 lang = 'en' 233 title = u'English' 234 235 class French(LanguageLink): 236 """A link to switch to French. 237 """ 238 lang = 'fr' 239 title = u'Français' 240 241 class German(LanguageLink): 242 """A link to switch to German. 243 """ 244 lang = 'de' 245 title = u'Deutsch' 246 247 class Hausa(LanguageLink): 248 """A link to switch to Hausa. 249 """ 250 lang = 'ha' 251 title = u'Hausa' 252 253 class Yoruba(LanguageLink): 254 """A link to switch to Yoruba. 255 """ 256 lang = 'yo' 257 title = u'Yoruba' 258 219 preferred_languages = getUtility(ISIRPUtils).PREFERRED_LANGUAGES_DICT 220 html = u'' 221 for key, value in sorted( 222 preferred_languages.items(), key=lambda lang: lang[1][0]): 223 args = {'lang':key, 'view_name':self.view.__name__} 224 url = self.view.url( 225 self.context) + '/@@change_language?%s' % urlencode(args) 226 html += u'| <a href="%s" title="%s">%s</a> ' % (url, value[1], key) 227 return html 259 228 260 229 # Problem with circular references. Disabled for now... -
main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py
r7681 r7701 43 43 # (e.g. object histories). 44 44 PORTAL_LANGUAGE = 'en' 45 46 PREFERRED_LANGUAGES_DICT = { 47 'en':(1, u'English'), 48 'fr':(2, u'Français'), 49 'de':(3, u'Deutsch'), 50 'ha':(4, u'Hausa'), 51 'yo':(5, u'Yoruba'), 52 } 45 53 46 54 def getInstTypeDict(self):
Note: See TracChangeset for help on using the changeset viewer.