From f3436e1d78c0ab9472f7b5eb52e7bf2aff185f27 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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/readme.md b/readme.md index 606f46c..7f7054f 100644 --- a/readme.md +++ b/readme.md @@ -24,3 +24,29 @@ from tcii18n import Translator translator = Translator('my_file.csv') translator.translate('My string') ``` + +In a flask project: + +*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") }}

+``` + +Where: + +-get_translations_file() is a function that returns the appropriate translation file path +-flask_methods(app, get_translation_file) initializes the template processor +with app as your Flask instance and get_translation_file is the reference + to the callable method.