diff --git a/BABEL_USAGE.md b/BABEL_USAGE.md new file mode 100644 index 0000000..3b7e9d1 --- /dev/null +++ b/BABEL_USAGE.md @@ -0,0 +1,17 @@ +# Babel usage +Babel will scan and detect sections of code that uses `gettext` or `_` in HTML templates and python code. It takes the constant string passed into its function and makes a translation template which can then be used to build individual translations. + +## Usage +If you are compiling and building a template from scratch +``` +$ pybabel extract -F babel.cfg -o messages.pot ./ +$ pybabel update -i messages.pot -d translations +``` + +Make translations in the outputted file then compile the translation with +``` +$ pybabel compile -d translations +``` + +Make sure the `messages.po` file is in the right language directory. +Example path: `translations/nb/LC_MESSAGES/messages.po` diff --git a/README.md b/README.md index 753028a..ffb6939 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,13 @@ Install the required dependencies with pip ``` $ pip install -r requirements.txt ``` -then, run the web server +Make sure you compile the babel languages +``` +$ pybabel compile -d translations +``` +Lastly, run the web server ``` $ python3 main.py ``` -Configuration can be edited in config.json \ No newline at end of file +Configuration can be edited in config.json diff --git a/requirements.txt b/requirements.txt index 13a2d6e..cb3cbd3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Flask>=1.0.2 Flask-WTF>=0.14.2 flask_login>=0.4.1 +Flask-Babel>=0.12.2 bcrypt \ No newline at end of file