Giter Site home page Giter Site logo

django-phrase's People

Contributors

docstun avatar dyve avatar egze avatar forelabs avatar francawinter avatar itsahsiao avatar kennell avatar kevvvvv avatar lookasc avatar louisamon avatar maranik avatar sacry-dyn avatar sbruhns avatar strzibny avatar thesoenke avatar timleers avatar tobstarr avatar varpuspaavi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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

django-phrase's Issues

Folder naming structure django

We have setup language "en-US" and "nb-NO" for our project. When we pull from phrase, the folder name inside locale becomes, "en-US", "nb-NO".
When we try to run "django-admin compilemessages --all", "invalid locale en-US, did you mean en_US?" we get this error. By default i guess django look for folder named as "Locale_name". Is there any alternate solution to fix this issue or any wayaround?

Django-version:3.2.9
django-phrase:1.0.8

Add tests

This package is missing unit tests in specific Python and Django combinations. Tox would be a good tool for this. Are you considering adding this?

cannot import name 'TOKEN_TEXT'

When loading {% load phrase_i18n %} in my Django templates, These three errors occur. Which I think it is caused in the phrase.compact

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/home/ibrahim/workspace//venv/lib/python3.6/site-packages/django/template/utils.py", line 66, in __getitem__
    return self._engines[alias]
KeyError: 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 121, in get_package_libraries
    module = import_module(entry[1])
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/phrase/templatetags/phrase_i18n.py", line 4, in <module>
    from django.template.base import TOKEN_TEXT, TOKEN_VAR
ImportError: cannot import name 'TOKEN_TEXT'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/channels/management/commands/runserver.py", line 69, in inner_run
    self.check(display_num_errors=True)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/contrib/admin/checks.py", line 79, in check_dependencies
    for engine in engines.all():
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "/home/ibrahim/workspace/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 125, in get_package_libraries
    "trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'phrase.templatetags.phrase_i18n': cannot import name 'TOKEN_TEXT'

Phrase In-Context not working for Django 4

my requirements.txt
asgiref==3.5.0
backports.zoneinfo==0.2.1
Django==4.0.4
django-phrase==1.0.8
six==1.16.0
sqlparse==0.4.2

After following the readme.md tutorial, phrase footerbar is showing, but editor not working. No translation is showing as key.

Type comparison - 'SafeText' object has no attribute 'literal'

Hi there!

I've been doing some work integrating Phrase with one of our Django apps recently and have run into an interesting behaviour.

First off, the library works really well to get us off the ground quickly, so thank you!

In some cases (such as the template snippet below), the __safer_name function in utils will be given a SafeText object instead of a string:

Works fine:

<h1>{% trans "Add" %}</h1>

Throws the exception in the title ('SafeText' object has no attribute 'literal')

{% trans "Add" as heading_name %}

<h1>{{ heading_name }}</h1>

The second case fails the type check type(self.name) is text_type as it is not a string, and so the second branch is executed producing the exception. If we change it to isinstance(self.name, text_type) (so that the type check includes ancestor types) the template snippets above both work as expected and the text is rendered correctly.

From here I have a couple of questions:

  1. Am I doing something wrong to produce this, or is this an unsupported way of using translated strings and Phrase together? (I can produce this in both our application and a fresh django app)

  2. Would the use of isinstance be a sensible change to include in the library? (there are plenty of compatibility questions to be answered first, I imagine)

Finally, I'm reasonably new to python and django, so please correct me if I'm missing some knowledge from general best practice!

Two import errors

After installing phrase I get two errors:

1: ImportError raised loading phrase.templatetags.phrase_i18n: cannot import name render_value_in_context

in nodes.py importing render_value_in_context fails because (in django 1.4) this method name starts with an underscore.
so:
from django.template.base import render_value_in_context
should be:
from django.template.base import _render_value_in_context as render_value_in_context

2: File "..phrase/templatetags/phrase_i18n.py", line 67, in top
m = re.match("^'([^']+)'(|.*$)", value)

NameError: global name 're' is not defined
(running python 2.7)
obviously to be solved by adding "import re" in phrase_i18n.py

Template Tag {% blocktrans %} results in AttributeError or TemplateSyntaxError

After installing, adding and configuring django-phrase in our project I discovered a problem with the blocktrans template tag. There are two different errors:

  1. Just blocktrans tag
  2. The blocktrans tag with argument trimmed

To provoke the described bugs install django-demo-application and change line <h1>{% trans 'ThisIsH1' %}</h1> within polls/template/index.html to raise appropriate bug/problem.

  1. Just blocktrans tag
    <h1>
    {% blocktrans %}
    ThisIsH1.
    Or at least,
    should be!
    {% endblocktrans %}
    </h1>

Results in:
AttributeError at /polls/
'unicode' object has no attribute 'literal'

  1. The blocktrans tag with argument trimmed
    <h1>
    {% blocktrans trimmed %}
    ThisIsH1.
    Or at least,
    should be!
    {% endblocktrans %}
    </h1>

Results in:
TemplateSyntaxError at /polls/
Unknown argument for u'blocktrans' tag: u'trimmed'.

Both versions of code work if you disable
{% load phrase_i18n %}
{% phrase_javascript %}
within above mentioned index.html file. For more information see attached Traceback files.

20170315_PhraseApp Bug Blocktrans Trimmed.txt
20170315_PhraseApp Bug Blocktrans.txt

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.