Giter Site home page Giter Site logo

callmefredcom / babelboilerplate Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14 KB

Flask Babel Boilerplate

Home Page: https://youtu.be/bACbM76kt3c

Python 20.43% CSS 2.30% JavaScript 28.84% HTML 48.43%
babel flask flask-application python translation translation-management

babelboilerplate's Introduction

Instructions to use Flask Babel

https://python-babel.github.io/flask-babel/

Install Flask Babel

pip install Flask-Babel

Directories

Create /translations directory at the root of the project

Create /lg directory for each supported language (e.g. /en, /fr,โ€ฆ)

Create /LC_MESSAGES folder under each supported language

add & configure babel.cfg file at the root of the project

[jinja2: templates/**.html]
[python: **.py]

Extract text strings from our HTML templates and .py files

pybabel extract -F babel.cfg -o messages.pot .

It creates a messages.pot file

Then initialize language translation files, it will create a .po file, here for French (fr)

pybabel init -i messages.pot -d translations -l fr

Note: if you want to later update the .po file after creating a new messages.pot file

pybabel update -d translations -i messages.pot -l fr

Translate the strings

Then translate all the msgid entries in the .po file as msgstr

You can give the full content to ChatGPT and ask it to generate the translations.

Finally, compile the .po file to a .mo file

pybabel compile -d translations

Don't forget to import babel as shown in our boilerplate

from flask_babel import Babel, _,lazy_gettext as _l, gettext

Follow the instructions for the full configuration.

babelboilerplate's People

Contributors

callmefredcom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.