Add better trans and clean up template

This commit is contained in:
Gonzalo Pena-Castellanos 2017-09-28 16:51:17 -04:00
parent 5d63f18ef6
commit fccdbb6b73
2 changed files with 44 additions and 44 deletions

View file

@ -4,7 +4,7 @@ home = Home
edit_on_github = Edit on GitHub edit_on_github = Edit on GitHub
create_on_github = Translate on GitHub create_on_github = Translate on GitHub
translation_out_of_date = This translation of the original content is out of date! translation_out_of_date = This translation of the original content is out of date!
see_original_content = See original content see_original_content = See what changed in the original content
update_translation = Update translation on Github update_translation = Update translation on Github
; Footer ; Footer

View file

@ -1,23 +1,23 @@
{% from "macros/translation.html" import transbag %} {%- from "macros/translation.html" import transbag -%}
{% macro menu_item(identifier) %} {%- macro menu_item(identifier) -%}
{% set identifier_url = '/' + identifier %} {%- set identifier_url = '/' + identifier -%}
{% set trans_url = identifier_url|url(alt=this.alt) %} {%- set trans_url = identifier_url|url(alt=this.alt) -%}
{% set this_is_child = this.is_child_of(identifier_url) %} {%- set this_is_child = this.is_child_of(identifier_url) -%}
<li class="nav-item{% if this_is_child %} active{% endif %}"> <li class="nav-item{% if this_is_child %} active{% endif %}">
<a class="nav-link" href="{{ trans_url }}">{{ transbag('menu', this.alt, identifier) }}{% if this_is_child %}<span class="sr-only">(current)</span>{% endif %}</a> <a class="nav-link" href="{{ trans_url }}">{{- transbag('menu', this.alt, identifier) -}}{%- if this_is_child -%}<span class="sr-only">(current)</span>{%- endif -%}</a>
</li> </li>
{% endmacro %} {%- endmacro -%}
{% set t_languages = transbag('menu', this.alt, 'languages') %} {%- set t_languages = transbag('menu', this.alt, 'languages') -%}
{% set t_sitemap = transbag('translate', this.alt, 'sitemap') %} {%- set t_sitemap = transbag('translate', this.alt, 'sitemap') -%}
{% set t_welcome = transbag('translate', this.alt, 'welcome') %} {%- set t_welcome = transbag('translate', this.alt, 'welcome') -%}
{% set t_edit_on_github = transbag('translate', this.alt, 'edit_on_github') %} {%- set t_edit_on_github = transbag('translate', this.alt, 'edit_on_github') -%}
{% set t_create_on_github = transbag('translate', this.alt, 'create_on_github') %} {%- set t_create_on_github = transbag('translate', this.alt, 'create_on_github') -%}
{% set t_translation_out_of_date = transbag('translate', this.alt, 'translation_out_of_date') %} {%- set t_translation_out_of_date = transbag('translate', this.alt, 'translation_out_of_date') -%}
{% set t_see_original_content = transbag('translate', this.alt, 'see_original_content') %} {%- set t_see_original_content = transbag('translate', this.alt, 'see_original_content') -%}
{% set t_update_translation = transbag('translate', this.alt, 'update_translation') %} {%- set t_update_translation = transbag('translate', this.alt, 'update_translation') -%}
{% set diff = alt_outdated_diff(this) %} {%- set diff = alt_outdated_diff(this) -%}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -27,7 +27,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge"> <meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{% block title %}{{ t_welcome }}{% endblock %} — BeeWare</title> <title>{%- block title %}{{- t_welcome -}}{% endblock -%} — BeeWare</title>
<!-- Fav and touch icons --> <!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/images/brutus-144.png"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/images/brutus-144.png">
@ -46,7 +46,7 @@
{%- if diff -%} {%- if diff -%}
<!-- Project CSS --> <!-- Project CSS -->
{{ get_pygments_css_styles('default')|safe }} {{- get_pygments_css_styles('default')|safe -}}
{%- endif -%} {%- endif -%}
<!-- Font Awesome --> <!-- Font Awesome -->
@ -63,7 +63,7 @@ ga('create', 'UA-2943925-4', 'pybee.org');
ga('send', 'pageview'); ga('send', 'pageview');
</script> </script>
{% block extra_head %}{% endblock %} {%- block extra_head -%}{%- endblock -%}
</head> </head>
<body> <body>
@ -83,44 +83,44 @@ ga('send', 'pageview');
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{{ t_languages }} <span class="caret"></span></a> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{{ t_languages }} <span class="caret"></span></a>
<div class="dropdown-menu" aria-labelledby="dropdown01"> <div class="dropdown-menu" aria-labelledby="dropdown01">
{% set eng_active = this.alt == 'en' %} {%- set eng_active = this.alt == 'en' %}
<a class="dropdown-item {% if eng_active %}active{% endif %}" href="{{ '.'|url(alt='en') }}">English</a> <a class="dropdown-item {% if eng_active %}active{% endif %}" href="{{ '.'|url(alt='en') }}">English</a>
{% for alt, alternative in config.ALTERNATIVES.items()|sort %} {%- for alt, alternative in config.ALTERNATIVES.items()|sort -%}
{% set alt_active = alt == this.alt %} {%- set alt_active = alt == this.alt -%}
{% if alt != config.primary_alternative %} {%- if alt != config.primary_alternative -%}
<a class="dropdown-item {% if alt_active %}active{% endif %}" href="{{ '.'|url(alt=alt) }}">{{ alternative.name.en }}</a> <a class="dropdown-item {% if alt_active %}active{% endif %}" href="{{ '.'|url(alt=alt) }}">{{ alternative.name.en }}</a>
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
</div> </div>
</li> </li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{% set extra_slash = '/' if this.path[-1] != '/' else '' %} {%- set extra_slash = '/' if this.path[-1] != '/' else '' -%}
{% set alt_path = '%2B' + this.alt if this.alt and this.alt != 'en' else '' %} {%- set alt_path = '%2B' + this.alt if this.alt and this.alt != 'en' else '' -%}
<li class="small"> <li class="small">
{% if this.alt in get_alts(source=this, fallback=False) %} {%- if this.alt in get_alts(source=this, fallback=False) -%}
{% set edit_link = 'https://github.com/pybee/pybee.github.io/edit/lektor/content' + this.path.split('@')[0] + extra_slash + 'contents' + alt_path + '.lr' %} {%- set edit_link = 'https://github.com/pybee/pybee.github.io/edit/lektor/content' + this.path.split('@')[0] + extra_slash + 'contents' + alt_path + '.lr' -%}
<a href="{{ edit_link }}" target="_blank"> <a href="{{ edit_link }}" target="_blank">
<i class="fa fa-github "></i><small>&nbsp;{{ t_edit_on_github }}</small> <i class="fa fa-github "></i><small>&nbsp;{{ t_edit_on_github }}</small>
</a> </a>
{% else %} {%- else -%}
{# This method is provided by a custom plugin found in /packages/lektor_pybee_plugin/ #} {# This method is provided by a custom plugin found in /packages/lektor_pybee_plugin/ #}
{% set content_value = urlencode_limit(site.get(this.path).contents.as_text(), limit=5000) %} {%- set content_value = urlencode_limit(site.get(this.path).contents.as_text(), limit=5000) -%}
{% if content_value and '@' not in this.path %} {%- if content_value and '@' not in this.path -%}
<a href="https://github.com/pybee/pybee.github.io/new/lektor/content{{ this.path }}/contents{{ alt_path }}.lr?filename=contents{{ alt_path }}.lr&value={{ content_value }}" target="_blank"> <a href="https://github.com/pybee/pybee.github.io/new/lektor/content{{ this.path }}/contents{{ alt_path }}.lr?filename=contents{{ alt_path }}.lr&value={{ content_value }}" target="_blank">
<i class="fa fa-github "></i><small>&nbsp;{{ t_create_on_github }}</small> <i class="fa fa-github "></i><small>&nbsp;{{ t_create_on_github }}</small>
</a> </a>
{% endif %} {%- endif -%}
{% endif %} {%- endif -%}
</li> </li>
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="content"> <div class="content">
{% block preamble %} {%- block preamble -%}
{% endblock %} {%- endblock -%}
<div class="container"> <div class="container">
{% if this.alt in get_alts(source=this, fallback=False) and diff %} {%- if this.alt in get_alts(source=this, fallback=False) and diff -%}
<div class="alert alert-warning"> <div class="alert alert-warning">
<i class="fa fa-warning"></i>&nbsp;{{ t_translation_out_of_date }}&nbsp;&nbsp; <i class="fa fa-warning"></i>&nbsp;{{ t_translation_out_of_date }}&nbsp;&nbsp;
<a href="{{ site.get(this.path)|url }}" data-toggle="modal" data-target="#myModal">{{ t_see_original_content }}</a> <a href="{{ site.get(this.path)|url }}" data-toggle="modal" data-target="#myModal">{{ t_see_original_content }}</a>
@ -140,22 +140,22 @@ ga('send', 'pageview');
</a> </a>
</h4> </h4>
</div> </div>
<div class="modal-body">
<small> <small>
{{- diff|safe -}} {{- diff|safe -}}
</small> </small>
<div class="modal-body">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div> </div>
</div> </div>
<!-- End Modal content -->
</div> </div>
</div> </div>
<!-- End modal --> <!-- End Modal -->
{% endif %} {%- endif -%}
{% block body %}{% endblock %} {%- block body -%}{%- endblock -%}
</div> </div>
</div> </div>
@ -177,6 +177,6 @@ ga('send', 'pageview');
<script src="/static/tether-1.3.3/js/tether.min.js"></script> <script src="/static/tether-1.3.3/js/tether.min.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script> <script src="/static/bootstrap/js/bootstrap.min.js"></script>
{% block extra_script %}{% endblock %} {%- block extra_script -%}{%- endblock -%}
</body> </body>
</html> </html>