forked from miguelgrinberg/microblog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a650e6f
commit 8a56c34
Showing
20 changed files
with
402 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import click | ||
from app import app | ||
|
||
|
||
@app.cli.group() | ||
def translate(): | ||
"""Translation and localization commands.""" | ||
pass | ||
|
||
|
||
@translate.command() | ||
@click.argument('lang') | ||
def init(lang): | ||
"""Initialize a new language.""" | ||
if os.system('pybabel extract -F babel.cfg -k _l -o messages.pot .'): | ||
raise RuntimeError('extract command failed') | ||
if os.system( | ||
'pybabel init -i messages.pot -d app/translations -l ' + lang): | ||
raise RuntimeError('init command failed') | ||
os.remove('messages.pot') | ||
|
||
|
||
@translate.command() | ||
def update(): | ||
"""Update all languages.""" | ||
if os.system('pybabel extract -F babel.cfg -k _l -o messages.pot .'): | ||
raise RuntimeError('extract command failed') | ||
if os.system('pybabel update -i messages.pot -d app/translations'): | ||
raise RuntimeError('update command failed') | ||
os.remove('messages.pot') | ||
|
||
|
||
@translate.command() | ||
def compile(): | ||
"""Compile all languages.""" | ||
if os.system('pybabel compile -d app/translations'): | ||
raise RuntimeError('compile command failed') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block app_content %} | ||
<h1>Not Found</h1> | ||
<p><a href="{{ url_for('index') }}">Back</a></p> | ||
<h1>{{ _('Not Found') }}</h1> | ||
<p><a href="{{ url_for('index') }}">{{ _('Back') }}</a></p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block app_content %} | ||
<h1>An unexpected error has occurred</h1> | ||
<p>The administrator has been notified. Sorry for the inconvenience!</p> | ||
<p><a href="{{ url_for('index') }}">Back</a></p> | ||
<h1>{{ _('An unexpected error has occurred') }}</h1> | ||
<p>{{ _('The administrator has been notified. Sorry for the inconvenience!') }}</p> | ||
<p><a href="{{ url_for('index') }}">{{ _('Back') }}</a></p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.