Get l10n working. Anonymous users can choose a language through a form on the sidebar. Authenticated users can set a language in their user settings.
This commit is contained in:
parent
16b80d3257
commit
708506e273
11 changed files with 2016 additions and 478 deletions
1
fas/.gitignore
vendored
1
fas/.gitignore
vendored
|
@ -8,4 +8,5 @@ fas.log
|
|||
*.pyc
|
||||
*.pyo
|
||||
*.swp
|
||||
*.mo
|
||||
fas.egg-info
|
||||
|
|
|
@ -59,6 +59,8 @@ genshi.encoding="utf-8"
|
|||
# i18n
|
||||
session_filter.on = True
|
||||
i18n.run_template_filter = True
|
||||
i18n.domain = 'fas'
|
||||
i18n.locale_dir = 'po'
|
||||
|
||||
# VISIT TRACKING
|
||||
# Each visit to your application will be assigned a unique visit ID tracked via
|
||||
|
|
|
@ -5,6 +5,7 @@ from cherrypy import request, response
|
|||
|
||||
from turbogears import exception_handler
|
||||
import turbogears
|
||||
import cherrypy
|
||||
import time
|
||||
|
||||
from fas.user import User
|
||||
|
@ -24,6 +25,17 @@ def add_custom_stdvars(vars):
|
|||
|
||||
turbogears.view.variable_providers.append(add_custom_stdvars)
|
||||
|
||||
def get_locale(locale=None):
|
||||
if locale:
|
||||
return locale
|
||||
if turbogears.identity.current.user_name:
|
||||
person = People.by_username(turbogears.identity.current.user_name)
|
||||
return person.locale
|
||||
else:
|
||||
return turbogears.i18n.utils._get_locale()
|
||||
|
||||
config.update({'i18n.get_locale': get_locale})
|
||||
|
||||
# from fas import json
|
||||
# import logging
|
||||
# log = logging.getLogger("fas.controllers")
|
||||
|
@ -101,6 +113,14 @@ class Root(controllers.RootController):
|
|||
|
||||
@expose()
|
||||
def logout(self):
|
||||
identity.current.logout()
|
||||
turbogears.flash(_('You have successfully logged out.'))
|
||||
identity.current.logout()
|
||||
raise redirect(request.headers.get("Referer", "/"))
|
||||
|
||||
@expose()
|
||||
def language(self, locale):
|
||||
locale_key = config.get("i18n.session_key", "locale")
|
||||
cherrypy.session[locale_key] = locale
|
||||
raise redirect(request.headers.get("Referer", "/"))
|
||||
|
||||
|
||||
|
|
|
@ -189,6 +189,21 @@ a
|
|||
background: #082C59;
|
||||
}
|
||||
|
||||
#language
|
||||
{
|
||||
padding: 1ex;
|
||||
}
|
||||
|
||||
#language label
|
||||
{
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
#language input
|
||||
{
|
||||
width: 4ex;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
margin-left: 22ex;
|
||||
|
|
|
@ -64,6 +64,13 @@
|
|||
<li><a href="${tg.url('/group/list/A*')}">${_('Apply For a new Group')}</a></li>
|
||||
<li><a href="http://fedoraproject.org/wiki/FWN/LatestIssue">${_('News')}</a></li>
|
||||
</ul>
|
||||
<div py:if="tg.identity.anonymous" id="language">
|
||||
<form action="${tg.url('/language')}" method="get">
|
||||
<label for="locale">${_('Locale:')}</label>
|
||||
<input type="text" name="locale" id="locale" />
|
||||
<input type="submit" value="${_('OK')}" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div py:if="tg_flash" class="flash">
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<title>${_('Fedora Accounts System')}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>${_{'Fedora Project OpenID Provider')}</h2>
|
||||
<h2>${_('Fedora Project OpenID Provider')}</h2>
|
||||
<p>
|
||||
${Markup_('Description goes here, <a href="http://username.fedorapeople.org/">username.fedorapeople.org</a>'))}
|
||||
${Markup_('Description goes here, <a href="http://username.fedorapeople.org/">username.fedorapeople.org</a>')}
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<input type="hidden" id="url" name="url" value="${url}" />
|
||||
<input type="checkbox" id="trusted" name="trusted" value="allow" />
|
||||
<label for="trusted">${Markup(_('Allow <strong>%s</strong> to authenticate to your OpenID identity?') % url)}</label><br />
|
||||
<input type="submit" value="${_('Submit'}" />
|
||||
<input type="submit" value="${_('Submit')}" />
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
|
|
|
@ -54,6 +54,16 @@
|
|||
</select>
|
||||
<script type="text/javascript">var hb7 = new HelpBalloon({dataURL: '/fas/help/get_help/user_timezone'});</script>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="locale">${_('Locale')}:</label>
|
||||
<input type="text" id="locale" name="locale" value="${target.locale}" />
|
||||
<!--
|
||||
<select id="locale" name="locale">
|
||||
option py:for="locale in available_locales" value="${locale}" py:attrs="{'selected': target.locale == locale and 'selected' or None}">${locale}</option>
|
||||
</select>
|
||||
-->
|
||||
<!--<script type="text/javascript">var hb7 = new HelpBalloon({dataURL: '/fas/help/get_help/locale'});</script>-->
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="comments ">${_('Comments')}:</label>
|
||||
<textarea id="comments" name="comments">${target.comments}</textarea>
|
||||
|
|
|
@ -203,7 +203,7 @@ class User(controllers.Controller):
|
|||
@validate(validators=UserSave())
|
||||
@error_handler(error)
|
||||
@expose(template='fas.templates.user.edit')
|
||||
def save(self, targetname, human_name, telephone, postal_address, email, ircnick=None, gpg_keyid=None, comments='', timezone='UTC'):
|
||||
def save(self, targetname, human_name, telephone, postal_address, email, ircnick=None, gpg_keyid=None, comments='', locale='en', timezone='UTC'):
|
||||
username = turbogears.identity.current.user_name
|
||||
target = targetname
|
||||
person = People.by_username(username)
|
||||
|
@ -222,6 +222,7 @@ class User(controllers.Controller):
|
|||
target.telephone = telephone
|
||||
target.postal_address = postal_address
|
||||
target.comments = comments
|
||||
target.locale = locale
|
||||
target.timezone = timezone
|
||||
except TypeError:
|
||||
turbogears.flash(_('Your account details could not be saved: %s' % e))
|
||||
|
@ -375,6 +376,7 @@ class User(controllers.Controller):
|
|||
# TODO: Move this out to a single function (same as
|
||||
# CLA one), think of how to make sure this doesn't get
|
||||
# full of random keys (keep a clean Fedora keyring)
|
||||
# TODO: MIME stuff?
|
||||
try:
|
||||
subprocess.check_call([config.get('gpgexec'), '--keyserver', config.get('gpg_keyserver'), '--recv-keys', person.gpg_keyid])
|
||||
except subprocess.CalledProcessError:
|
||||
|
|
File diff suppressed because it is too large
Load diff
1392
fas/po/test/LC_MESSAGES/fas.po
Normal file
1392
fas/po/test/LC_MESSAGES/fas.po
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue