Skip to content

Commit

Permalink
Add flask documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ydrasil committed Jun 6, 2017
1 parent 9c4eefe commit e88d318
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,28 @@ from tcii18n import Translator
translator = Translator('my_file.csv')
translator.translate('My string')
```

For using this project into a Flask application.
You have to import `flask_methods` from `tcii18n.template`
Create a function that return the name of the translation file.
Call `flask_methods` with `app` and the function.
After that, you can use the function `_` or `trans` in your template for translation.

A minimal example :

*core.py*

```
from tcii18n.template import flask_methods
def get_translations_file():
return 'path/to/my/file.csv'
flask_methods(app, get_translations_file)
```

*template.html*

```
<h1>{{ _("Sentence") }}</h1>
```

0 comments on commit e88d318

Please sign in to comment.