Questions tagged [python-babel]

Python internationalization library with an emphasis on web-based applications. Use with the [python] tag and any relevant version tags.

158 questions
13
votes
1 answer

How to use python csv.DictReader with a binary file? (For a babel custom extraction method)

I'm trying to write a custom extraction method for babel, to extract strings from a specific column in a csv file. I followed the documentation here. Here is my extraction method code: def extract_csv(fileobj, keywords, comment_tags, options): …
tiagosilva
  • 1,695
  • 17
  • 31
13
votes
2 answers

Flask Babel - 'translations/de/LC_MESSAGES/messages.po' is marked as fuzzy, skipping

I cant get a basic translationto work in Flask Babel. Here are my steps. I have this in a page {{_("Hello")}} I run this command. pybabel extract -F babel.cfg -o messages.pot . I then run this command for German. pybabel init -i messages.pot -d…
Tampa
  • 75,446
  • 119
  • 278
  • 425
13
votes
1 answer

Extracting gettext strings from Javascript and HTML files (templates)

I know that there are at least two ways to extract gettext strings from .js files - using the gettext parser in python mode (which I've heard has some shortcomings) and Babel, which is written in python. Is there way to extract gettext strings from…
ragulka
  • 4,312
  • 7
  • 48
  • 73
12
votes
1 answer

GAE webapp application internationalization with Babel

How would you go about internationalizing a Google App Engine webapp application using BABEL? I am looking here for all the stages: Marking the strings to be translated. Extracting them. Traslating Configuring your app to load the right language…
12
votes
2 answers

With Jinja2 and Babel, how do I translate sentences containing HTML tags?

Suppose I have a Jinja2 template, and I'm using Flask-Babel to translate my project. For example:

The best way of using the Internet is to use our site.

So I have a sentence with a link and an…
Ken Kinder
  • 12,654
  • 6
  • 50
  • 70
12
votes
1 answer

Language Localization of Khan Academy

I am currently working on language localization of Khan Academy, I have downloaded the source 8051 from Google Code . After survey information and viewing code online, the project is made using jinja2 as the templating language. I can use babel to…
11
votes
1 answer

Access a Flask extension that is defined in the app factory

I am using the app factory pattern to set up my Flask application. My app uses the Flask-Babel extension, and that is set up in the factory as well. However, I want to access the extension in a blueprint in order to use it, The factory is in…
Tinker
  • 4,165
  • 6
  • 33
  • 72
10
votes
1 answer

Using Babel: How to protect translator comments (and old translations) in GNU gettext PO files?

With the Python-based Babel gettext utilities, are there any techniques to preserve translator comments and old ("obsolete") translations (marked with #~) in .po files across updates from the .pot file? The first time an obsolete translation is in a…
Malcolm
  • 5,125
  • 10
  • 52
  • 75
10
votes
2 answers

translating strings from database flask-babel

I'm using Flask-Babel for translating string. In some templates I'm reading the strings from the database(postgresql). How can I translate the strings from the database using Flask-Babel?
gulic
  • 123
  • 5
10
votes
2 answers

How to use jinja2 and its i18n extension (using babel) outside flask

How can I use jinja2 with babel outside a flask application. Supposing that I have locale dir which is populated using pybabel command. I want to load translation files and translate my template files.
Ali
  • 931
  • 10
  • 22
9
votes
1 answer

How can I choose the language, using Flask + Babel?

Now I'm developing a project, which should support two languages: English, as default, and Russian. It's pretty easy to do, using HTTP_ACCEPT_LANGUAGE header, the code is bellow: babel = Babel(app) @babel.localeselector def get_locale(): return…
Sergey Potekhin
  • 621
  • 1
  • 11
  • 27
9
votes
2 answers

Internationalizing a Python 2.6 application via Babel

We're evaluating Babel 0.9.5 [1] under Windows for use with Python 2.6 and have the following questions that we we've been unable to answer through reading the documentation or googling. 1) I would like to use an _ like abbreviation for ungettext.…
Malcolm
  • 5,125
  • 10
  • 52
  • 75
8
votes
1 answer

compile translation files when calling setup.py install

I'm developing a Flask application using Babel. Thanks to Distutils/Setuptools Integration, all the parameters of compile/extract/... functions are stored in setup.cfg and compiling the i18n files is as easy as ./setup.py compile_catalog Great.…
Jérôme
  • 13,328
  • 7
  • 56
  • 106
8
votes
3 answers

Flask babel not working on simple translation?

Ok I have the following app: babel.cfg [python: **.py] [jinja2: **/templates/**.html] extensions=jinja2.ext.autoescape,jinja2.ext.with_ lucy/init.py babel = Babel() def create_app(object_name): app = Flask(__name__) …
Tinker
  • 4,165
  • 6
  • 33
  • 72
8
votes
4 answers

Pybabel generates empty pot file with jinja2

I'm using Flask, Flask-Babel and Jinja2. I'm trying to generate the .pot file. That what I did so far. My babel.cfg looks like this: [python: **.py] [jinja2: **.html] encoding = utf-8 extensions=jinja2.ext.autoescape,jinja2.ext.with_ I'm…
Or Duan
  • 13,142
  • 6
  • 60
  • 65
1
2 3
10 11