From e88d318c2e46f592dd7efd90fdd43a891722943e Mon Sep 17 00:00:00 2001 From: Hugo MOCHET Date: Tue, 6 Jun 2017 17:45:12 +0200 Subject: [PATCH] Add flask documentation --- readme.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/readme.md b/readme.md index 606f46c..0a165e5 100644 --- a/readme.md +++ b/readme.md @@ -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* + +``` +

{{ _("Sentence") }}

+```