Coder Social home page Coder Social logo

django-babel's People

Contributors

akx avatar ashemedai avatar cmlenz avatar entequak avatar felixschwarz avatar graingert avatar mjtamlyn avatar mrunge avatar noirbizarre avatar orf avatar ramiro avatar robhudson avatar sarina avatar singingwolfboy avatar tsouvarev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-babel's Issues

ImportError when running the extraction process

Hello, I had an ImportError when extracting the messages of my Django app. The message error was the following one:

from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
ImportError: cannot import name 'TOKEN_TEXT' from 'django.template.base' (c:\users\artac\appdata\local\programs\python\python37-32\lib\site-packages\django\template\base.py)

I managed to solve it by making some changes in the django_babel/extract.py file. Those changes where:

  1. Changing the line 2 imports to this: from django.template.base import Lexer, TokenType
  2. Changing the extract_django(fileobj, keywords, comment_tags, options) method, replacing every TOKEN_BLOCK to TokenType.BLOCK, TOKEN_TEXT to TokenType.TEXT and TOKEN_VAR to TokenType.VAR.

My package versions are:

  • Django==2.1.7
  • django-babel==0.6.2
  • Babel==2.6.0

Put documentation somewhere

would be nice if you'd put the documentation somewhere, either ask mitsuhiko on IRC if you can have a django-babel.pocoo.org documentation or use readthedocs.org, would be my recommendation.

support "trimmed" in blocktrans

Django 1.7 added a "trimmed" option for blocktrans tags. When that's enabled, then it strips whitespace from the beginning and end of strings as well as collapses consecutive whitespace characters in the string.

I'm pretty sure django-babel's extractor doesn't support that.

Is that correct? If so, can support for that be added?

Release for compatibility support

Hi !

Django 1.10 support has been added in #33 and is merged but not yet released.

Is it possible to release this to be able to use it with Django 1.10 ?

Thansk by advance !

Translations in template vars with a macro are not picked up

When upgrading a project from Django 1.6 to 1.8, several libraries had to be updated as well. One of them was BabelDjango 0.2.2 to django-babel 0.4.0.

One particular type of translation in templates was no longer picked up by the extract function in pybabel. When I run pybabel extract and pybabel update on the following template:

<html>
{% trans "test1" %}

{{ _('test2') }}

{% macro label(label) %}
    <label>{{ label }}</label>
{% endmacro %}

{{ label(_('test3')) }}

{% call macros.label(_('test4')) %}{% endcall %}
</html>

The output is:

#: templates2/staff/base.tmpl:3
msgid "test1"
msgstr ""

#: templates2/staff/base.tmpl:4
msgid "'test2'"
msgstr ""

#: templates2/staff/base.tmpl:12
msgid "'test4'"
msgstr ""

So test3 is not picked up anymore. I tried several combinations and/or versions of libraries, but could not get it to work with Django 1.8. I also compared the extract functions that both BabelDjango 0.2.2 and django-babel 0.4.0 use and not much changed there. My guess is that the extract function in django-babel does not pick up this translation with Django's template engine changes.

Installed packages (where "test3" is not picked up by extract)

Django==1.8.9
Jinja2==2.7.1
django_jinja==2.1.1
Babel==2.2.0
django-babel==0.4.0

Installed packages (where "test3" is picked up by extract)

Django==1.6.10
Jinja2==2.7.1
jingo==0.6.1
Babel==1.3
BabelDjango==0.2.2

tox -e docs fails

tox -edocs
GLOB sdist-make: /home/mrunge/work/django-babel/setup.py
docs inst-nodeps: /home/mrunge/work/django-babel/.tox/dist/django-babel-0.4.0.zip
docs installed: alabaster==0.7.7,Babel==2.2.0,Django==1.9.2,django-babel==0.4.0,docutils==0.12,Jinja2==2.8,MarkupSafe==0.23,Pygments==2.1.1,pytz==2015.7,six==1.10.0,snowballstemmer==1.2.1,Sphinx==1.3.5,sphinx-rtd-theme==0.1.9
docs runtests: PYTHONHASHSEED='2878308748'
docs runtests: commands[0] | sphinx-build -W -b html -d /home/mrunge/work/django-babel/.tox/docs/tmp/doctrees docs /home/mrunge/work/django-babel/.tox/docs/tmp/_build/html
Running Sphinx v1.3.5
making output directory...
loading pickled environment... not yet created
loading intersphinx inventory from https://docs.python.org/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 5 source files that are out of date
updating environment: 5 added, 0 changed, 0 removed
reading sources... [ 20%] extract
reading sources... [ 40%] index
reading sources... [ 60%] management-commands
reading sources... [ 80%] middleware
reading sources... [100%] template-tags


Warning, treated as error:
/home/mrunge/work/django-babel/docs/template-tags.rst:4: WARNING: autodoc: failed to import module u'django_babel.templatetags.babel'; the following exception was raised:
Traceback (most recent call last):
  File "/home/mrunge/work/django-babel/.tox/docs/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
    __import__(self.modname)
  File "/home/mrunge/work/django-babel/.tox/docs/lib/python2.7/site-packages/django_babel/templatetags/babel.py", line 3, in <module>
    from babel import support as babel_support
ImportError: cannot import name support

ERROR: InvocationError: '/home/mrunge/work/django-babel/.tox/docs/bin/sphinx-build -W -b html -d /home/mrunge/work/django-babel/.tox/docs/tmp/doctrees docs /home/mrunge/work/django-babel/.tox/docs/tmp/_build/html'

Django 1.10 support

It doesn't seem to work with django 1.10, I guess just upgrading the checker to accept 1.10 would be enough:

pkg_resources.VersionConflict: (Django 1.10 (/x/y/z/lib/python3.5/site-packages), Requirement.parse('django<1.10,>=1.4'))

Deactivate travis push builds

One usually only needs merge PR builds and not building pushes speeds up the merge process.

Just a recommendation :) I usually do that for all my repos.

percent signs escaping en trans/blocktrans templatetags

When I look at the django source code, I see that % signs are escaped to %% during extraction [1] [2] then replaced by % during the rendering [3].

There is no such replacements during the extraction, but Django will still want to replace %% by %on rendering.

If you confirm my analysis, I can create a PR to fix the issue

[1] https://github.com/django/django/blob/stable/1.11.x/django/utils/translation/template.py#L182
[2] https://github.com/django/django/blob/stable/1.11.x/django/utils/translation/template.py#L145
[3] https://github.com/django/django/blob/master/django/templatetags/i18n.py#L86

Django 2.1.* support

Hi!

Currently, we faced the following issue for Django 2.1.* series:

django_babel/extract.py", line 2, in <module>
    from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
ImportError: cannot import name 'TOKEN_TEXT'

Package versions:

  • Django==2.1.5
  • Babel==2.6.0
  • django-babel==0.6.2

So there need to add some compatibility. I'm in progress with the PR now.

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.