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
2
votes
0 answers

How to localize humanized time formatting

How can I localize to get nice humanized output of the time for an article like Today 16:48 or Yesterday 17:10 or 13 Dec 11:20 from webapp2_extras.i18n import gettext as _ import datetime from datetime import date, datetime, time from…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
2
votes
1 answer

How do I make Babel use minus signs?

Why is it that Babel does not use the minus sign used by my locale, in functions like format_decimal()? It seems to me like this would be the very job of a library like Babel. Is there a way I can enforce the usage of locale specific minus…
leo
  • 8,106
  • 7
  • 48
  • 80
2
votes
1 answer

Flask-Babel language selector

Hello it is a pleasure to greet you, today I come to ask you for help with an error that Babel de Flask is presenting to me, I am new to the subject, but in advance I thank you for your collaboration. At the end of the code I show in a Quote the…
Khöug
  • 46
  • 7
2
votes
0 answers

Get a list of translated nationality names with python and babel (or maybe something else?)

I need to write a multilingual program where users can set their home country and nationality on their profile pages. I can get a list of country names with python and babel easily. For example, to get "german" language name in slovakian: from babel…
nagylzs
  • 3,954
  • 6
  • 39
  • 70
2
votes
2 answers

How to get a specific language translation using pybabel

Most of the time, using Babel's gettext() or _() is with a current locale set within the current context, so that the target language is implicit, it is not passed as an argument to gettext(). However, is there a way to get the translation of a…
patb
  • 1,688
  • 1
  • 17
  • 21
2
votes
2 answers

How do I add a link to change and keep a new language using babel and flask?

I have setup Babel correctly and the translation work as intended. What I am stuck with is to be able to switch languages using a link and than keep that setting active even if the user click on any other links on the web page. This is what my setup…
Salviati
  • 758
  • 2
  • 9
  • 28
2
votes
2 answers

KeyError: 'babel' - related to __init__.py - Not using Babel explicitly

I've been getting the same error for hours, no matter what code changes I make, and it's referencing Babel, a dependency I am not specifically calling or using, although I assume it's being called for a reason. It's coming from a function that is…
km457
  • 125
  • 2
  • 11
2
votes
0 answers

Blank Django ReactJS Webpage With No Errors

I have followed a lot of examples about how to setup Django and ReactJS for Django to serve up static files using the Django Web server. I believe I have a good working version but for some reason, I get a blank page but with no errors. I am new to…
Axwack
  • 569
  • 1
  • 8
  • 26
2
votes
2 answers

Extract messages programmatically with PyBabel

Right now, I’m extracting messages using pybabel extract -F babel.cfg -o messages.pot . This walks through all my Python files and extracts messages correctly. However, I call this through subprocess.call(), which is pretty ugly, given PyBbel is…
GergelyPolonkai
  • 6,230
  • 6
  • 35
  • 69
2
votes
3 answers

Flask + Flask-Security + Babel not working

I have setup with Flask + Babel + Flask Security. Created all translation like this: root main.py translations ru LC_MESSAGES messages.mo messages.po In main.py there is part to setup language which executes: @babel.localeselector def…
andjelx
  • 199
  • 1
  • 13
2
votes
1 answer

Flask-Babel Multiple Language URL Routing

I am creating a multi-language site (EN and FR) and I need it to toggle back and forth on click if the user so chooses. I am using Flask-Babel and the translations and toggle are working correctly on click, however, I need the URLs to be translated…
kbdev
  • 1,225
  • 1
  • 13
  • 33
2
votes
1 answer

Extending Jinja's {% trans %} to use JavaScript variables

I'd like to extend the behaviour of trans by rendering variables not as as values from the context, but instead as html (without using the context). My aim is to be able to populate those variables on the client through JavaScript. Jinja as it seems…
orange
  • 7,755
  • 14
  • 75
  • 139
2
votes
1 answer

Using babel and lingua in pyramid

I've problems with babel and lingua. I want babel/lingua to scan my source folder for specific strings for creating the pot-catalog. This is my setup.py ... requires = [ ... 'Babel', 'lingua', ] extractors = { 'dbas': [ …
2
votes
1 answer

Retrieve string for unit test

Consider this code: def get_some_text(): return _(u"We need this text here") What is the best way to write a unit test that makes sure the function returns this - referenced and translated by Babel - string? This naive code would not contain a…
Thorben Croisé
  • 12,407
  • 8
  • 39
  • 50
2
votes
1 answer

Babel's message_extractors configuration in setup.py: Third parameter in tuple

I want to start using Babel with my Python project. I have a setup.py that has something along the following as per documentation: setup( ... message_extractors = {'my_project': [('**.py', 'lingua_python', None), ]}, ... And…
javex
  • 7,198
  • 7
  • 41
  • 60