Ignore:
Timestamp:
22 Feb 2012, 08:27:56 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement Language switch in the topbar and add some German translations for demonstration.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/browser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt

    r7665 r7674  
    3636  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    3737  ...Welcome to the...
     38  ...
     39
     40We can change to German::
     41  >>> browser.getLink('de').click()
     42  >>> print browser.contents
     43  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     44  ...Anfragen...
     45  ...
     46
     47And then change back to English by clicking on the third link containing 'en'
     48behind 'Anfragen' and 'Einloggen'::
     49  >>> browser.getLink('en', index=2).click()
     50  >>> print browser.contents
     51  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     52  ...Enquiries...
    3853  ...
    3954
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r7659 r7674  
    2626import time
    2727import re
     28import zope.i18nmessageid
    2829from zope import schema
    2930from zope.authentication.interfaces import (
     
    137138
    138139#
    139 # Login/logout pages...
     140# Login/logout and language switch pages...
    140141#
    141142
     
    187188            self.flash("You have been logged out. Thanks for using WAeUP SIRP!")
    188189        self.redirect(self.application_url())
     190
     191
     192class LanguageChangePage(SIRPPage):
     193    """ Language switch
     194    """
     195    grok.context(ISIRPObject)
     196    grok.name('change_language')
     197    grok.require('waeup.Public')
     198
     199    def update(self, lang='en', view_name='@@index'):
     200        self.response.setCookie('waeup.sirp.language', lang, path='/')
     201        self.redirect(self.url(self.context, view_name))
     202        return
     203
     204    def render(self):
     205        return
    189206
    190207#
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css

    r7635 r7674  
    193193  line-height: 18px;
    194194}
     195
     196.language {
     197  color: #BFBFBF;
     198  position:relative;
     199  top:10px;
     200  right:-160px;
     201}
     202
     203.language a {
     204  color: #BFBFBF;
     205}
     206
     207.language a:hover {
     208  color: #ffffff;
     209}
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultypage.pt

    r7464 r7674  
    1 <div tal:condition="python: not len(context.keys())">
     1<div i18n:domain="waeup.sirp" i18n:translate="" tal:condition="python: not len(context.keys())">
    22There no subobjects registered yet.
    33</div>
    44
    5 <table>
     5<table i18n:domain="waeup.sirp">
    66  <thead>
    77    <tr>
    8       <th>Code</th>
    9       <th>Title</th>
     8      <th i18n:translate="code">Code</th>
     9      <th i18n:translate="title">Title</th>
    1010    </tr>
    1111  </thead>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/staffsitelayout.pt

    r7669 r7674  
    11<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2 <html xmlns="http://www.w3.org/1999/xhtml"
    3       xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    4       i18n:domain="waeup.sirp"
    5       xml:lang="en">
     2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" i18n:domain="waeup.sirp">
    63  <head>
    74    <title>WAeUP - your way up
     
    2926          <ul class="nav secondary-nav">
    3027            <li tal:condition="not: layout/isAuthenticated">
    31             <a href="#" i18n:translate="login"
     28            <a href="#" i18n:translate=""
    3229                tal:attributes="href python: view.url(layout.site, 'login')">
    3330                Login
     
    3532            </li>
    3633            <li tal:condition="layout/isAuthenticated">
    37             <a href="#" tal:attributes="href python: view.url(layout.site, '@@contactadmin')">
     34            <a href="#" i18n:translate=""
     35               tal:attributes="href python: view.url(layout.site, '@@contactadmin')">
    3836                Contact
    3937            </a>
    4038            </li>
    4139            <li tal:condition="layout/isAuthenticated">
    42             <a href="#" tal:attributes="href python: view.url(context, '@@logout')">Logout</a>
     40            <a href="#" i18n:translate=""
     41               tal:attributes="href python: view.url(context, '@@logout')">Logout</a>
    4342            </li>
    4443          </ul>
     44          <span class="language">
     45            <tal:languages
     46                  tal:content="structure provider:languages" /> |
     47          </span>
    4548        </div>
    4649      </div>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/studentsitelayout.pt

    r7669 r7674  
    11<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2 <html xmlns="http://www.w3.org/1999/xhtml"
    3       xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    4       i18n:domain="waeup.sirp"
    5       xml:lang="en">
     2<html xmlns="http://www.w3.org/1999/xhtml" i18n:domain="waeup.sirp">
    63  <head>
    74    <title>WAeUP - your way up
     
    3431          <ul class="nav secondary-nav">
    3532            <li tal:condition="not: layout/isAuthenticated">
    36             <a href="#" tal:attributes="href python: view.url(layout.site, 'login')">
     33            <a href="#" i18n:translate=""
     34               tal:attributes="href python: view.url(layout.site, 'login')">
    3735                Login
    3836            </a>
    3937            </li>
    4038            <li tal:condition="layout/isAuthenticated">
    41             <a href="#" tal:attributes="href python: view.url(layout.site, '@@contactadmin')">
     39            <a href="#" i18n:translate=""
     40               tal:attributes="href python: view.url(layout.site, '@@contactadmin')">
    4241                Contact
    4342            </a>
    4443            </li>
    4544            <li tal:condition="layout/isAuthenticated">
    46             <a href="#" tal:attributes="href python: view.url(context, '@@logout')">Logout</a>
     45            <a href="#" i18n:translate=""
     46               tal:attributes="href python: view.url(context, '@@logout')">Logout</a>
    4747            </li>
    4848          </ul>
     49          <span class="language">
     50            <tal:languages
     51                  tal:content="structure provider:languages" /> |
     52          </span>
    4953        </div>
    5054      </div>
    5155    </div>
     56
    5257    <div class="container">
    5358      <ul class="student-info-bar" tal:condition="layout/isAuthenticated">
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r7461 r7674  
    1717##
    1818import grok
     19import zope.i18nmessageid
     20from urllib import urlencode
    1921from zope.component import getMultiAdapter, queryAdapter
    2022from zope.interface import Interface
     
    3335from waeup.sirp.utils.helpers import get_user_account
    3436
     37_ = zope.i18nmessageid.MessageFactory('waeup.sirp')
     38
    3539grok.templatedir('templates')
    3640grok.context(ISIRPObject) # Make ISIRPObject the default context
     
    4145class BreadCrumbManager(grok.ViewletManager):
    4246    grok.name('breadcrumbs')
     47
     48class LanguageManager(grok.ViewletManager):
     49    grok.name('languages')
    4350
    4451class ActionBar(grok.ViewletManager):
     
    200207                    url = self.view.url(breadcrumb.context, breadcrumb.target)
    201208                    )
     209
     210class LanguageLink(grok.Viewlet):
     211    """ An entry in the language selector.
     212
     213    This is only a baseclass that won't be rendered actually. Deriving
     214    viewlets can override certain values and will be rendered with the
     215    values set here as default.
     216    """
     217    grok.baseclass()
     218    grok.viewletmanager(LanguageManager)
     219    grok.context(ISIRPObject)
     220    grok.require('waeup.Public')
     221    lang = 'de'
     222    title = u'Deutsch'
     223
     224    def render(self):
     225        args = {'lang':self.lang, 'view_name':self.view.__name__}
     226        url = self.view.url(
     227            self.context) + '/@@change_language?%s' % urlencode(args)
     228        return u'| <a href="%s" title="%s">%s</a> ' % (url,self.title,self.lang)
     229
     230class English(LanguageLink):
     231    """A link to switch to English.
     232    """
     233    lang = 'en'
     234    title = u'English'
     235
     236class French(LanguageLink):
     237    """A link to switch to French.
     238    """
     239    lang = 'fr'
     240    title = u'Fran&ccedil;ais'
     241
     242class German(LanguageLink):
     243    """A link to switch to German.
     244    """
     245    lang = 'de'
     246    title = u'Deutsch'
     247
     248class Hausa(LanguageLink):
     249    """A link to switch to Hausa.
     250    """
     251    lang = 'ha'
     252    title = u'Hausa'
     253
     254class Yoruba(LanguageLink):
     255    """A link to switch to Yoruba.
     256    """
     257    lang = 'yo'
     258    title = u'Yoruba'
    202259
    203260
     
    623680
    624681    pnav = 1
    625     tab_title = u'Academics'
     682    tab_title = _(u'Academics')
    626683
    627684    @property
     
    638695    grok.order(6)
    639696    grok.require('waeup.Anonymous')
    640     tab_title = u'Enquiries'
     697    tab_title = _(u'Enquiries')
    641698    pnav = 2
    642699
Note: See TracChangeset for help on using the changeset viewer.