Skip to content

Commit

Permalink
First commit with Flask-Babel and Spanish translation of account view…
Browse files Browse the repository at this point in the history
…. Refs Scifabric#43
  • Loading branch information
teleyinex committed Mar 26, 2013
1 parent 63f2c56 commit 40c9c0a
Show file tree
Hide file tree
Showing 20 changed files with 1,586 additions and 147 deletions.
5 changes: 5 additions & 0 deletions pybossa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
#from flask.ext.debugtoolbar import DebugToolbarExtension
from flask.ext.cache import Cache
from flask.ext.heroku import Heroku
from flask.ext.babel import Babel

from pybossa import default_settings as settings

from raven.contrib.flask import Sentry


def create_app():
app = Flask(__name__)
if 'DATABASE_URL' in os.environ:
Expand All @@ -41,6 +43,7 @@ def create_app():
gravatar = Gravatar(app, size = 100, rating = 'g', default = 'mm', force_default = False, force_lower = False)
return app


def configure_app(app):
app.config.from_object(settings)
app.config.from_envvar('PYBOSSA_SETTINGS', silent=True)
Expand Down Expand Up @@ -92,3 +95,5 @@ def setup_logging(app):
signer = URLSafeTimedSerializer(app.config['ITSDANGEORUSKEY'])
if app.config.get('SENTRY_DSN'):
sentr = Sentry(app)

babel = Babel(app)
20 changes: 10 additions & 10 deletions pybossa/templates/_navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@
<a class="brand" href="{{ url_for('home') }}"><img src="{{url_for('static',filename='img/' + logo)}}" alt="{{brand}}"></a>
<div class="nav-collapse collapse">
<ul class="nav">
<li {% if active_page == 'community' %} class="active" {% endif %}><a href="{{ url_for('account.index')}}">Community</a></li>
<li {% if active_page == 'applications' %} class="active" {% endif %}><a href="{{ url_for('app.index') }}">Applications</a></li>
<li {% if active_page == 'create' %} class="active" {% endif %}><a href="{{ url_for('app.new') }}">Create</a></li>
<li {% if active_page == 'about' %} class="active" {% endif %}><a href="{{ url_for('about')}}">About</a></li>
<li {% if active_page == 'community' %} class="active" {% endif %}><a href="{{ url_for('account.index')}}">{{ _('Community') }}</a></li>
<li {% if active_page == 'applications' %} class="active" {% endif %}><a href="{{ url_for('app.index') }}">{{ _('Applications') }}</a></li>
<li {% if active_page == 'create' %} class="active" {% endif %}><a href="{{ url_for('app.new') }}">{{ _('Create') }}</a></li>
<li {% if active_page == 'about' %} class="active" {% endif %}><a href="{{ url_for('about')}}">{{ _('About') }}</a></li>
</ul>
{% include '_gcs_form.html' ignore missing %}
{% if current_user.is_authenticated() %}
<ul class="nav secondary-nav pull-right">
<li {% if active_page == 'profile' %} class="active" {% endif %}><a href="#" data-toggle="dropdown" class="dropdown-toggle"><i class="icon icon-user"></i> {{ current_user.name | truncate(8,true) }} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ url_for('account.profile') }}"><i class="icon icon-user"></i> My Profile</a></li>
<li><a href="{{ url_for('account.applications') }}"><i class="icon icon-th-large"></i> My Applications</a></li>
<li><a href="{{ url_for('account.settings') }}"><i class="icon icon-cog"></i> My Settings</a></li>
<li><a href="{{ url_for('account.profile') }}"><i class="icon icon-user"></i> {{ _('My Profile') }}</a></li>
<li><a href="{{ url_for('account.applications') }}"><i class="icon icon-th-large"></i> {{ _('My Applications') }}</a></li>
<li><a href="{{ url_for('account.settings') }}"><i class="icon icon-cog"></i> {{ _('My Settings') }}</a></li>
{% if current_user.admin == 1 %}
<li class="divider"></li>
<li><a href="{{ url_for('admin.index') }}"><i class="icon icon-cog"></i> Admin Site</a></li>
<li><a href="{{ url_for('admin.index') }}"><i class="icon icon-cog"></i> {{ _('Admin Site') }}</a></li>
{% endif %}
<li class="divider"></li>
<li><a href="{{ url_for('account.signout') }}"><i class="icon icon-off"></i> Sign Out</a></li>
<li><a href="{{ url_for('account.signout') }}"><i class="icon icon-off"></i> {{ _('Sign Out') }}</a></li>
</ul>
</li>
</ul>
{% endif %}

{% if current_user.is_anonymous() %}
<ul class="nav secondary-nav pull-right">
<li><a href="{{ url_for('account.signin') }}"><i class="icon icon-white icon-signin"></i> Sign in</a></li>
<li><a href="{{ url_for('account.signin') }}"><i class="icon icon-white icon-signin"></i> {{ _('Sign in') }}</a></li>
</ul>
{% endif %}
</div><!--/.nav-collapse -->
Expand Down
30 changes: 15 additions & 15 deletions pybossa/templates/account/_helpers.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{% macro render_account_local_nav(current_user, active_link) -%}
<ul data-spy="affix" data-offset-top="200px" class="nav nav-list bs-docs-sidenav affix-top">
<li {% if active_link=="profile"%}class="active"{% endif %}><a href="{{url_for('account.profile')}}"><i class="icon-chevron-right"></i> My Profile</a></li>
<li {% if active_link=="applications"%}class="active"{% endif %}><a href="{{url_for('account.applications')}}"><i class="icon-chevron-right"></i> My Applications</a></li>
<li {% if active_link=="profile"%}class="active"{% endif %}><a href="{{url_for('account.profile')}}"><i class="icon-chevron-right"></i> {{ _('My Profile') }}</a></li>
<li {% if active_link=="applications"%}class="active"{% endif %}><a href="{{url_for('account.applications')}}"><i class="icon-chevron-right"></i> {{ _('My Applications') }}</a></li>
{% if current_user.admin %}
<li {% if active_link=="admin"%}class="active"{% endif %}><a href="{{url_for('admin.index')}}"><i class="icon-chevron-right"></i> Admin Site</a></li>
<li {% if active_link=="admin"%}class="active"{% endif %}><a href="{{url_for('admin.index')}}"><i class="icon-chevron-right"></i> {{ _('Admin Site') }}</a></li>
{% endif %}
<li {% if active_link=="settings"%}class="active"{% endif %}><a href="{{url_for('account.settings')}}"><i class="icon-chevron-right"></i> My Settings</a></li>
<li {% if active_link=="settings"%}class="active"{% endif %}><a href="{{url_for('account.settings')}}"><i class="icon-chevron-right"></i> {{ _('My Settings') }}</a></li>
</ul>
{% endmacro %}

{% macro render_twitter_btn(app) %}
<a href="https://twitter.com/share" class="twitter-share-button"
data-text="I've done {{app.c}} tasks for the @PyBossa project: {{app.name}}. Do you want to help? {{url_for('app.details',short_name=app.short_name,_external=True)}}"
data-count="none">Tweet</a>
data-text="{{ _('I\'ve done') }} {{app.c}} {{ _('tasks for the @PyBossa project:') }} {{app.name}}. {{ _('Do you want to help?') }} {{url_for('app.details',short_name=app.short_name,_external=True)}}"
data-count="none">{{ _('Tweet') }}</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
{% endmacro %}

Expand All @@ -36,31 +36,31 @@
<img class="img-polaroid" src="{{ user.email_addr | gravatar(size=164)}}">
</div>
<div class="span9">
<h2><i class="icon-user"></i> Nick: <small>{{ user.name }}</small></h2>
<h2><i class="icon-user"></i> {{ _('Nick')}}: <small>{{ user.name }}</small></h2>
{% if private %}
<h2><i class="icon-envelope"></i> E-mail: <small>{{ user.email_addr }}</small></h2>
<h2><i class="icon-envelope"></i> {{_('E-mail')}}: <small>{{ user.email_addr }}</small></h2>
{% endif %}
{% if user.rank %}
<h2><i class="icon-trophy"></i> Rank: <small>
<h2><i class="icon-trophy"></i> {{ _('Rank')}}: <small>
{% if private %}
<a href="{{url_for('leaderboard.index')}}">
{% endif %}
{{ user.rank }} of {{user.total}} with a Score of {{user.score}} contributed tasks
{{ user.rank }} {{_('of')}} {{user.total}} {{ _('with a Score of')}} {{user.score}} {{ _('contributed tasks')}}
{% if private %}</a>{% endif %}
</small>
</h2>
{% else %}
<h2><i class="icon-trophy"></i> Rank: <small>The user has not contributed a task yet</small></h2>
<h2><i class="icon-trophy"></i> {{ _('Rank') }}: <small>{{ _('The user has not contributed a task yet') }}</small></h2>
{% endif %}
{% if not private %}
<h2><i class="icon-time"></i> Joined: <small>{{ user.created[0:10]}}</small></h2>
<h2><i class="icon-time"></i> {{ _('Joined') }}: <small>{{ user.created[0:10]}}</small></h2>
{% endif %}
{% if settings %}
<h2><i class="icon-key"></i> API key: <small>{{ user.api_key }}</small></h2>
<h2><i class="icon-key"></i> {{ _('API key') }}: <small>{{ user.api_key }}</small></h2>
{% endif %}
{% if private %}
<a href="{{ url_for('account.public_profile', name=user.name) }}" class="btn btn-inverse"><i class="icon icon-globe"></i> See your public profile</a>
<a href="{{ url_for('account.settings') }}" class="btn btn-primary"><i class="icon icon-user"></i> Edit your profile</a>
<a href="{{ url_for('account.public_profile', name=user.name) }}" class="btn btn-inverse"><i class="icon icon-globe"></i> {{ _('See your public profile') }}</a>
<a href="{{ url_for('account.settings') }}" class="btn btn-primary"><i class="icon icon-user"></i> {{ _('Edit your profile') }}</a>
{% endif %}
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions pybossa/templates/account/applications.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
{{ helper.render_account_local_nav(current_user, active_link) }}
</div>
<div class="span9" style="min-height:400px">
<h1><strong>{{ current_user.fullname }}'s</strong>: Applications</h1>
<h1><strong>{{ current_user.fullname }}'s</strong>: {{ _('Applications') }}</h1>
{% if apps_published or apps_draft %}
{% if apps_published %}
<h2>Published</h2>
<h2>{{ _('Published') }}</h2>
{% for app in apps_published %}
{{ app_helper.render_app_short_summary(app, current_user) }}
{% endfor %}
{% endif %}
{% if apps_draft %}
<h2>Draft</h2>
<h2>{{ _('Draft') }}</h2>
{% for app in apps_draft %}
{{ app_helper.render_app_short_summary(app, current_user) }}
{% endfor %}
{% endif %}
{% else %}
<h2>You have not created an application</h2>
<a href="{{url_for('app.new')}}" class="btn btn-primary">Create an Application</a>
<h2>{{ _('You have not created an application') }}</h2>
<a href="{{url_for('app.new')}}" class="btn btn-primary">{{ _('Create an Application') }}</a>
{% endif %}
</div>
</div>
Expand Down
7 changes: 3 additions & 4 deletions pybossa/templates/account/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% if pagination.has_prev %}
<li>
<a href="{{ url_for_other_page(pagination.page - 1)
}}">&laquo; Prev</a>
}}">&laquo; {{_('Prev')}}</a>
</li>
{% endif %}

Expand All @@ -27,7 +27,7 @@
{% if pagination.has_next %}
<li>
<a href="{{ url_for_other_page(pagination.page + 1)
}}">Next &raquo;</a>
}}">{{_('Next')}} &raquo;</a>
</li>
{% endif %}
</ul>
Expand All @@ -37,8 +37,7 @@
{% block content %}

<div class="row">
<div class="span9 offset2">
<h1>Community <small>{{total}} registered users</small><a class="pull-right btn btn-primary" href="{{url_for('leaderboard.index')}}"><i class="icon-trophy" style="color:white"></i> Leaderboard</a></h1>
<h1>{{ _('Community') }} <small>{{total}} {{ _('registered users') }}</small><a class="pull-right btn btn-primary" href="{{url_for('leaderboard.index')}}"><i class="icon-trophy" style="color:white"></i> {{ _('Leaderboard') }}</a></h1>
{% if accounts %}
<ul class="thumbnails">
{% for account in accounts %}
Expand Down
12 changes: 6 additions & 6 deletions pybossa/templates/account/password.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
{{ helper.render_account_local_nav(current_user, active_link) }}
</div>
<div class="span9">
<h1><strong>{{current_user.fullname}}</strong>: Change your Password</h1>
<h1><strong>{{current_user.fullname}}</strong>: {{ _('Change your Password') }}</h1>
<form method="post" class="form-horizontal" action="{{ url_for('account.change_password') }}">
<fieldset>
{{ form.id }}
{{ form.hidden_tag() }}
{{ render_field(form.current_password, placeholder="my current password") }}
{{ render_field(form.new_password, placeholder="my new password") }}
{{ render_field(form.confirm, placeholder="my new password again") }}
{{ render_field(form.current_password, placeholder= _('my current password') ) }}
{{ render_field(form.new_password, placeholder= _('my new password') ) }}
{{ render_field(form.confirm, placeholder= _('my new password again') ) }}
<div class="form-actions">
<input type="submit" value="Save the changes" class="btn btn-primary btn-large" />
<a href="{{ url_for('account.settings') }}" class="btn">Cancel</a>
<input type="submit" value="Save the changes" class="btn btn-primary btn-large" text={{ _('Save the Changes')}} />
<a href="{{ url_for('account.settings') }}" class="btn">{{ _('Cancel') }}</a>
</div>
</fieldset>
</form>
Expand Down
8 changes: 4 additions & 4 deletions pybossa/templates/account/password_forgot.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
{% block content %}
{% from "_formhelpers.html" import render_field %}

<legend>Reset your Password</legend>
<legend>{{ _('Reset your Password') }}</legend>
<form method="post" class="form-horizontal">
<fieldset>
{{ form.hidden_tag() }}
{{ render_field(form.email_addr, placeholder="my new password") }}
{{ render_field(form.email_addr, placeholder= _('my new password') ) }}
<div class="form-actions">
<input type="submit" value="Reset my Password" class="btn btn-primary btn-large" />
<a href="{{ url_for('account.signin') }}" class="btn">Cancel</a>
<input type="submit" value="Reset my Password" text="{{ _('Reset my Password') }}"class="btn btn-primary btn-large" />
<a href="{{ url_for('account.signin') }}" class="btn">{{ _('Cancel') }}</a>
</div>
</fieldset>
</form>
Expand Down
8 changes: 4 additions & 4 deletions pybossa/templates/account/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</div>
<div class="span9">
<h1><strong>{{current_user.fullname}}</strong></h1>
<h2>Your Profile</h2>
<h2>{{ _('Your Profile') }}</h2>
{{ helper.render_user_profile(current_user) }}
<hr>
<h2>Your Contributions</h2>
<h2>{{ _('Your Contributions') }}</h2>
{% for app in apps_contrib %}
<div class="row-fluid well well-small">
<div class="span3">
Expand All @@ -26,8 +26,8 @@ <h2>Your Contributions</h2>
</div>
<div class="span9">
<h2><a href="{{url_for('app.details', short_name=app.short_name)}}">{{app.name}}</a></h2>
<p><i class="icon-tasks"></i> You have contributed <strong>{{app.n_task_runs}}</strong> tasks</p>
<a class="btn btn-primary" href="{{url_for('app.presenter', short_name=app.short_name)}}"><i class="icon-thumbs-up"></i> Contribute!</a>
<p><i class="icon-tasks"></i> {{ _('You have contributed') }} <strong>{{app.n_task_runs}}</strong> {{ _('tasks') }}</p>
<a class="btn btn-primary" href="{{url_for('app.presenter', short_name=app.short_name)}}"><i class="icon-thumbs-up"></i> {{ _('Contribute!') }}</a>
</div>
</div><!-- end row-fluid -->
{% endfor %}
Expand Down
26 changes: 14 additions & 12 deletions pybossa/templates/account/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
{% block content %}
{% from "_formhelpers.html" import render_field %}
<p style="padding-top:5px;">
<span class="label label-warning"><i class="icon-bullhorn"></i> Note</span>
By click the <strong>Create account button</strong> below you are agreeing to
the <a target="blank" href={{terms_of_use | safe}}>terms of use</a> and
<a href={{data_use | safe}}>data</a>.
<span class="label label-warning"><i class="icon-bullhorn"></i> {{ _('Note') }}</span>
{{ _('By click the') }}
<strong>{{ _('Create account button') }}
</strong>{{ _('below you are agreeing to the') }}
<a target="blank" href={{terms_of_use | safe}}>{{ _('terms of use') }} </a>{{ _('and') }}
<a href={{data_use | safe}}>{{ _('data') }}</a>.
</p>

<legend>Create an account</legend>
<legend>{{ _('Create an account') }}</legend>
<form method="post" class="form-horizontal" action="{{ url_for('account.register') }}">
{{ form.hidden_tag() }}
<fieldset>
{{ render_field(form.fullname, placeholder="my full name") }}
{{ render_field(form.username, placeholder="myusername") }}
{{ render_field(form.email_addr, placeholder="[email protected]") }}
{{ render_field(form.password, placeholder="my secret password") }}
{{ render_field(form.confirm, placeholder="my secret password") }}
{{ render_field(form.fullname, placeholder= _('my full name')) }}
{{ render_field(form.username, placeholder= _('myusername')) }}
{{ render_field(form.email_addr, placeholder= _('[email protected]')) }}
{{ render_field(form.password, placeholder= _('my secret password')) }}
{{ render_field(form.confirm, placeholder= _('my secret password')) }}
<div class="form-actions">
<input type="submit" value="Create an account" class="btn btn-primary btn-large" />
<input type="reset" value="Cancel" class="btn" />
<input type="submit" value="{{ _('Create an account') }}" class="btn btn-primary btn-large" />
<input type="reset" value="{{ _('Cancel') }}" class="btn" />
</div>
</fieldset>
</form>
Expand Down
8 changes: 4 additions & 4 deletions pybossa/templates/account/reset-api-key.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
{{ helper.render_account_local_nav(current_user, active_link) }}
</div>
<div class="span9">
<h1><strong>{{current_user.fullname}}</strong>: Reset API Key</h1>
<h1><strong>{{current_user.fullname}}</strong>: {{ _(' Reset API Key') }}</h1>
<div class="alert alert-warning">
<strong>Note</strong> If you reset the API key, you will need to use the new generated key for any API call.
<strong>{{ _('Note') }}</strong>{{ _(' If you reset the API key, you will need to use the new generated key for any API call.') }}
</div>
<form class="form-horizontal" method="post" action="{{ url_for('account.reset_api_key')}}">
<h3><strong>Do you want to reset your personal API Key?</strong></h3>
<h3><strong>{{ _('Do you want to reset your personal API Key?') }}</strong></h3>
<div class="form-actions">
<input type="submit" class="btn btn-small" value="Yes"/>
<a href="{{ url_for('account.settings') }}" class="btn btn-large btn-primary">No, do not reset the API key!</a>
<a href="{{ url_for('account.settings') }}" class="btn btn-large btn-primary">{{ _('No, do not reset the API key!') }}</a>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 40c9c0a

Please sign in to comment.