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
0
votes
1 answer

How to dynamically switch jinja filter

I am currently making a web app that displays a list of transactions of the user. I want to make a setting to change the currency from USD to EUR. I am using custom filter in jinja: My custom filter and function: from forex_python.converter import…
aNdroid
  • 27
  • 1
  • 5
0
votes
1 answer

How to sort collections based on current user locale on a Django site

I need to sort a collection of objects by a utf-8 string property (built via ActiveRecord). Currently the code is sorting by ASCII order via the order_by method, however this needs to be changed to locale.strcoll. Unfortunately using the built in…
0
votes
1 answer

How to use translation in Flask?

I have an application in which I have managed to use translations for romanian and english. I want to press the button "english" and get the website translated in english and when pressing "romanian" the website should translate to romanian. I have…
moro_922
  • 113
  • 8
0
votes
1 answer

Flask Babel convert to original language when insert to database

I have a set of SelectField with Flask-WTF and I convert the default language with Flask-Babel. Here is the snippet of my code: from flask_babel import _, lazy_gettext as _l class PaymentStatus(enum.Enum): PENDING = _l('PENDING') COMPLETED…
Tri
  • 2,722
  • 5
  • 36
  • 65
0
votes
1 answer

How to fix "ValueError: Unknown extraction method 'jinja2'" error in Python ?( Jinja2 Internationalization ?)

I need to extract messages from jinja2 files from my pyramid web app, Babel has a three default extraction method (javascript, python, ignore). How can i add Jinja2 extraction method ? All my packages are updated (pyramid, setuptools, babel,…
Javad Asoodeh
  • 299
  • 3
  • 12
0
votes
0 answers

How can I format a date within a longer string in a Jinja template with flask_babel?

Within a jinja template, I have the following string # English

by John Smith on

# German

am

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
0
votes
1 answer

Translation between languages with different numbers of plurals

I am trying to create a translation file in simplified Chinese from an English source. This is all happening in a Flask project and I've been using Flask-Babel (so far successfully) to translate to Spanish and French. I added a Chinese translation…
Arnaud
  • 750
  • 10
  • 25
0
votes
1 answer

Flask App not calling Babel localeselector

I am adding localisation to my Flask app with Flask-Babel, and I cannot seem to change the language. I followed all the Babel instructions for creating the po/mo files - I don't believe my issue is related to the translation data... its that I…
user9277612
  • 497
  • 4
  • 14
0
votes
0 answers

Google App Engine - Python - Babel - write_mo()

I'm working on Google App Engine Python3.7 I wrote this working code based on what I learned here: http://babel.pocoo.org/en/latest/api/messages/mofile.html https://docs.python.org/3/library/gettext.html#gettext.NullTranslations.install import…
Paolo177
  • 366
  • 6
  • 18
0
votes
2 answers

get current language in flask appbuilder

I have a simple app wrote with Flask Appbuilder, the view.py is as follows. It is part of exmaple in http://flask-appbuilder.readthedocs.io/en/latest/views.html with a little change in method1 where I replaced return 'Hello' with a function that I…
rahram
  • 560
  • 1
  • 7
  • 21
0
votes
1 answer

babel extract html does't work

{{_('Filename')}} ({{ (filesVM.files | filter:fileSearch).length }} files)
kly_dream
  • 15
  • 5
0
votes
1 answer

Better python datetime display?

I'm using babel and pytz to get the time zones. However, for most of America, it maps to something not as helpful in a dropdown box: "America/New_York" displays "Eastern Time", "America/Nipigon" also displays "Eastern Time". Is there some way to do…
Timmy
  • 12,468
  • 20
  • 77
  • 107
0
votes
1 answer

Python: Why do I get this exception from Babel when calling from cron?

I'm getting this exception thrown from within the Python Babel package when my script calls a Babel function. The thing is when I run it from the command line it works okay. However, this is the error I get when I run it from cron. It seems though…
Ambrosio
  • 3,789
  • 6
  • 22
  • 13
0
votes
1 answer

Pybabel misses tagged messages in html files

I am working through Miguel Grinberg's new Flask tutorial and have made it to i18n/l10n. Half this chapter had been a headache. First, pybabel extract -F babel.cfg -k _l -o messages.pot doesn't run. All I get is: pybabel: error: no input files or…
Nick Bonne
  • 75
  • 7
0
votes
1 answer

Writing a babel message parser and file extension

I'd like to get babel parsing a file and find out translation strings that are simply starting with: (_ and ending to: ) So the translation part in the file.myext could be: (_ "message") String literals are always starting and ending with double…
MarkokraM
  • 980
  • 1
  • 12
  • 26