Git Product home page Git Product logo

django-rosetta's Introduction

Hi there 👋

I am a senior backend developer / architect with 20+ years experience, mostly working in Python and Django.

I help building extraordinary web experiences at Cruncher.

Marco's GitHub stats

django-rosetta's People

Contributors

artscoop avatar bashar avatar benebun avatar blackwizard avatar chenluyong avatar claudep avatar codeinthehole avatar cuchac avatar davidkuchar avatar dnaranjo89 avatar dotsbb avatar fladi avatar frohus avatar halitcelik avatar izimobil avatar jbaldivieso avatar kitsunde avatar maikelwever avatar malkstar avatar mbi avatar mondeja avatar nealtodd avatar patroqueeet avatar pgcd avatar scream4ik avatar sitenano avatar sleepyjames avatar soyuzbek avatar strycore avatar svdvonde 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-rosetta's Issues

Percent sign does not get escaped?

When i translate a text that contains a percent sign (see example below) I get fatal errors when trying to compile it. Rosetta doesn't seem to escape percent signs?

Original text: "Searches on the web with mobile devices have increased with 400% since last year."
Swedish translation: "Mobila sökningar har ökat med 400% det senaste året."

Error message from compilemessages:
/sv/LC_MESSAGES/django.po:1705: number of format specifications in 'msgid' and 'msgstr' does not match

And the translation module then throws the following error:
TypeError: %d format: a number is required, not dict

Use of messages variable causes conflict in django messages framework

Hi,

we use the django messages framework to pass notices to pages in our website. Unfortunately rosetta uses the local variable messages (line 200 in views.py). Due to the variable being named "messages" and the variable being returned in the response context we've found that the messages framework gets trodden on.

Would it be possible to use a different name for this variable in views.py (and pofile.html)?

NoneType object has no attribute split

Hi all,

I'm using Django 1.4 and rosetta 0.6.8.

Somehow when I translate a few entries and click at the save button a few times, or even when I just click at the paginator links, after a few clicks I end up with this error message.

The problem can be resolved by restarting Apache.

Does anyone know what could be causing this?

Move from Bing to Azure for translation suggestions

Microsoft Translator API has moved to Azure DataMarket. I believe, currently the Bing API is still working despite Microsoft's announcement of terminating the service as of August 1st, 2012. Not sure about that, but it's probably a good idea to move to Azure ... it's actually just changing a few lines of codes and introducing two new values as a replacement for BING_APP_ID in settings.py.

Here's how to use Microsofts translator on Azure:
https://github.com/openlabs/Microsoft-Translator-Python-API

Kind regards

Auto reload with manage.py runfcgi

Is there a way to have rosetta reload translations when started with manage.py runfcgi?

I have tried with
ROSETTA_WSGI_AUTO_RELOAD = True
and
ROSETTA_UWSGI_AUTO_RELOAD = True

with no luck.

Thank you.

Can't click language files from /rosetta/ in non chrome browser on osx.

On the main listing page for the language files I can' click on a file to go to the next page. It just reloads the current page over and over again, I can make it go by repeatedly and rapidly clicking the link.

Chrome doesn't appear to have this issue but firefox and safari both do on OSX 10.8.

THe link appears to go to http://<my_domain>.com/rosetta/select/fr/0/ however clicking it just reloads /rosetta/.

Have I included URLs improperly somewhere?

Layout bug in Firefox 10+

In Firefox version 10+ the translation table with all the message files is shifted to the right - as far as the end of the search form above. Please ad an overflow:hidden to #toolbar in rosetta.css to fix it:

toolbar { height:20px;overflow: hidden}

Or place a
below the toolbar

tag.

Thanks for the great app!!

django 1.5a issue with 'rosetta-pick-file'

TemplateSyntaxError at /rosetta/
Could not parse the remainder: '-pick-file' from 'rosetta-pick-file'
In template /flow/venv/local/lib/python2.7/site-packages/rosetta/templates/rosetta/languages.html, error at line 7

Looks like django 1.5 doesn't support this sort of url names.

UnicodeDecodeError when I click on "Third party"

I get a UnicodeDecodeError whenever I click on the "Third party" pill in rosetta. This is what I get:

Unicode error hint:
The string that could not be encoded/decoded was: �mirat

Environment:


Request Method: GET
Request URL: http://localhost:8000/rosetta/pick/

Django Version: 1.5.1
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'rosetta',
 'south',
 'formapp')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  25.                 return view_func(request, *args, **kwargs)
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/rosetta/views.py" in list_languages
  336.             sorted([(get_app_name(l), os.path.realpath(l), pofile(l)) for l in  pos], key=lambda app: app[0]),
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/rosetta/polib.py" in pofile
  110.     return _pofile_or_mofile(pofile, 'pofile', **kwargs)
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/rosetta/polib.py" in _pofile_or_mofile
  76.     instance = parser.parse()
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/site-packages/rosetta/polib.py" in parse
  1210.         for line in self.fhandle:
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/codecs.py" in next
  684.         return self.reader.next()
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/codecs.py" in next
  615.         line = self.readline()
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/codecs.py" in readline
  530.             data = self.read(readsize, firstline=True)
File "/Users/daniel/Privat/virtualenvs/pcnform/lib/python2.7/codecs.py" in read
  477.                 newchars, decodedbytes = self.decode(data, self.errors)

Exception Type: UnicodeDecodeError at /rosetta/pick/
Exception Value: 'utf8' codec can't decode byte 0x83 in position 0: invalid start byte

After that, I need to stop the development server and restart it again, but it always happens if I click on that link.

Support --no-wrap option and/or different line wrap lengths

I am constantly having issues where the manage.py makemessages command which I use to update the file line numbers with creates strings where the line wrap occurs at a different point than when the files are saved by translators using rosetta. This means that diffs include a lot of noise where the only change is a single word on the following line.

I can turn off line wrapping with the --no-wrap option in makemessages but there is no similar capability in rosetta. It seems like polib supports this to some extent. I would assume setting wrapwidth to 0 would do it. Would it be possible to add a ROSETTA_WRAPWIDTH setting?

Urls reversing not working on Django 1.5.1

The url reverse in Django 1.5.1 is now in the format {% url 'app:url_name' %}, which is not compatible anymore with the current Rosetta templates.

Error is the following:

TemplateSyntaxError: Could not parse the remainder: '-pick-file' from 'rosetta-pick-file'. The syntax of 'url' changed in Django 1.5, see the docs.

Any chance this could be updated to Django 1.5.1?

WSGI reload button

It would be nice if there could reload the wsgi and uwsgi processes manually, auto_reloading is not a good choice on production and it is not even neccesary to apply new translation for every page that is saved...

It could be written quite easily as I can see from glancing at the code - the code that reloads wsgi is this:

if rosetta_settings.WSGI_AUTO_RELOAD and \
    'mod_wsgi.process_group' in request.environ and \
    request.environ.get('mod_wsgi.process_group', None) and \
    'SCRIPT_FILENAME' in request.environ and \
    int(request.environ.get('mod_wsgi.script_reloading', '0')):
        try:
            os.utime(request.environ.get('SCRIPT_FILENAME'), None)
        except OSError:
            pass
# Try auto-reloading via uwsgi daemon reload mechanism
if rosetta_settings.UWSGI_AUTO_RELOAD:
    try:
        import uwsgi
        # pretty easy right?
        uwsgi.reload()
    except:
        # we may not be running under uwsgi :P
        pass    

The reason why I did not fork implemented is that I have no idea where to put the reload button and what should I call it - maybe something like "Apply changes"

Not working with signed_cookie session backend

Hi MBI,

I finally got the time to track down the bug I reported a while ago:

Rosetta is not working, when cookie-based sessions are enabled. That's a new session backend on Django 1.4:
https://docs.djangoproject.com/en/dev/topics/http/sessions/#using-cookie-based-sessions

Since you store the whole PO file in sessions, the cookie can easily exceed the common 4 kb limit and thus, simply gets deleted before it's processed. That's what happens in all our projects. I don't know how big your PO files are or if you ever tested against the cookie-based session backend ... to enable and check this bug, add the following line to your settings.py:

SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'

Then try selecting a reasonably sized PO file in Rosetta, that exceeds 4 kb.

p.s.
I fixed it by not writing the whole PO data into the session, but reading it directly from the PO file as needed. However, I assume, there will be issues, since you would have done that in the first place. I can send you the modified views.py if you like.

p.s.s.
Also, could you please add #toolbar {height:20px;overflow:hidden;} to your css style sheet. The layout bug is still there in FF 12.0, even if you can't see it: #27

Problem on production server

Hi. on my production server i use MemcachedCache
And when i click link to select lang (/rosetta/select/en/0/) i redirect to home without form to edit translations

On my locale mac this work fine

Reload .po file

If I add a new trans/blocktrans in a template, for example, it would appear there's no
way to get it into Rosetta without executing makemessages from the shell.

Could this be implemented?

user session broken in some rare cases

To reproduce this issue:

  • session backend is cached or cached_db,
  • cache backend is memcached
  • po file is 700kb or more

as lang_sel view stores po file in session, and memcached doesn't store values bigger than 1Mb, session is cut and some data may be lost

Disable fuzzy strings

Having two different kinds of translations (fuzzy, and untranslated) confuses new translators in our code-base. So we would like to disable the fuzziness matching, and show all strings as untranslated instead. So this is a feature request for a setting that does this.

Ideally, this should be done in Django, but they have firmly stated that feature as wontfix: https://code.djangoproject.com/ticket/10852 - so I'm hoping you will take up this usability issue instead :)

Problem with language code sr-Latn.

There is no way I can see translation for this language code sr-Latn or sr-latn. Probably django is expecting folder name sr_Latn to look for translation files.

Keyboard shortcuts

It would be nice if one could control rosetta with keyboard shortcuts...

examples:

  • save file
  • copy from original
  • restart wsgi process

Copy from original

There should be button or something to copy translation from original - something that poeditor does have

urlpatterns - low priority

NOTE: This is a somewhat low priority issue, but I just happened to come across it.

I am in the habit of making the end slash optional - ex.

url(r'^ckeditor/?$', include('ckeditor.urls')),

When I tried this with Rosetta, it causes an error due to 'rosetta-pick-file' in the base template

Replacing with the explicit end slash

url(r'^rosetta/', include('rosetta.urls')), 

seems to solve cause no problems at all.

Adding Google Translate API v2 support

Unfortunately Bing translator API that is added in 0.6.3 support only few languages for translation.

Is adding a Google Translate API v2 support reasonable option for you, since it is paying service.

Some tests fail

These two tests fail. Specifically it's a second part of the tests that fail where you're checking that the locale file exists in the response content. I looked at this issue and the reason is because you're checking for Unix paths but on a windows machine, it returns "rosetta\locale\xx\LC_MESSAGES\django.po". This should be fairly minor to fix.

   def test_6_ExcludedApps(self):

        rosetta_settings.EXCLUDED_APPLICATIONS = ('rosetta',)

        r = self.client.get(reverse('rosetta-pick-file') +'?filter=third-party')
        r = self.client.get(reverse('rosetta-pick-file'))
        self.assertTrue('rosetta/locale/xx/LC_MESSAGES/django.po' not in r.content)

        rosetta_settings.EXCLUDED_APPLICATIONS = ()

        r = self.client.get(reverse('rosetta-pick-file') +'?rosetta')
        self.assertTrue('rosetta/locale/xx/LC_MESSAGES/django.po' in r.content)

    def test_7_selfInApplist(self):    
        self.client.get(reverse('rosetta-pick-file') +'?filter=third-party')
        r = self.client.get(reverse('rosetta-pick-file'))
        self.assertTrue('rosetta/locale/xx/LC_MESSAGES/django.po' in r.content)

        self.client.get(reverse('rosetta-pick-file') + '?filter=project')
        r = self.client.get(reverse('rosetta-pick-file'))
        self.assertTrue('rosetta/locale/xx/LC_MESSAGES/django.po' not in r.content)

Save redirect not working and occasionally failing to save

The initial problem I have is that the "save and translate next block" doesn't navigate forward to the next block, it simply saves the translations on the current page and redisplays it.

After hitting save, it is possible to move forward manually using the numbered page links which is what I've asked my translator to do.

However the bigger problem is that after repeating the above for several pages, on the ~6th page of translations the save button redirects back to the Language selection page and the most recent set of translations are lost. Previously saved pages are retained.

Seems likely to be an issue with session/caching but I have no idea where to start....

Django 1.4 and Rosetta 0.6.8.

I experience the issue under two server configurations:

  • nginx in front of Gunicorn
  • 'runserver' (daemonised under screen)

Configuration:

ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage'
SESSION_COOKIE_SECURE = False
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'dwight-dev',
}
}

local dir in project root is ignored

I use one project wide locale/ directory in the project root (same dir as manage.py) but i am unable to get rosetta to detect these localisation files. I've tried both the stable and develop (0.7.0) release and both show the django and third-party messages in the overview but the project overview just says "Nothing to translate!".

Submit button doesn't redirect to next page

The "Save and translate next block" saves but doesn't bring me to the next page.

pretty obvious, so i thought it was my fault. but i debugged the code and i'm pretty sure now...its a bug.

i'm using django-rosetta 0.6.2 and django-trunk.

regards,
klemens

module named six

Hello i am using django 1.5 with custom auth. I have installed development branch of rosetta in order to use it with django 1.5.
I am getting module named six error when try to reach http://127.0.0.1:8000/rosetta/

usage on read-only filesystem

when rosetta (v. 0.6.2 with django 1.3.1) is used on read-only filesystem, it doesn't store data in session, so downloading updated .po file is impossible and translated phrases disappears after swiching to another page. checked with current version, 0.6.2 and 0.6.0

Support for msgctxt option

When trying to save a translation string that has the msgctxt parameter, whatever you type in seems not to be saved. The form is submitted but changes are not applied. Furthermore, the translator's view shows the context hint but no longer shows the translator's hint text:

An example would be:

forms.py:

# Translators: this is a note to translators
label = pgettext_lazy("Street Address", "Address")

output of makemessages command:

#. Translators: this is a note to translators
#: forms.py:123
msgctxt "Street Address"
msgid "Address"
msgstr ""

The above is what is output by django's makemessages command.

Is the msgctxt parameter supported by rosetta?

Translation Suggestions

I'm using Rosetta 0.6.4.

I enabled the translation suggestions via Bing, but I can't see any button/link to trigger them...

settings.py:

# Rosetta configuration
ROSETTA_MESSAGES_PER_PAGE = 20
ENABLE_TRANSLATION_SUGGESTIONS = True
BING_APP_ID = 'my_id'
ROSETTA_MESSAGES_SOURCE_LANGUAGE_CODE = 'de'
ROSETTA_MESSAGES_SOURCE_LANGUAGE_NAME = 'German'

The ROSETTA_MESSAGES_PER_PAGE option works, so the configuration should basically work.

PS: Thanks for making this amazing app :)

Autoreload with gunicorn?

Is there any chance to reload translation with gunicorn?
Something similar to ROSETTA_WSGI_AUTO_RELOAD and ROSETTA_UWSGI_AUTO_RELOAD.

support for 1.4

on running rosetta in development trunk, I get this error

Environment:

Request Method: GET
Request URL: http://127.0.0.1:9999/rosetta/

Django Version: 1.4a1
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.staticfiles',
'sorl.thumbnail',
'south',
'web',
'modeltranslation',
'rosetta')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')

Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/usr/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  2.             return view_func(request, _args, *_kwargs)
    
    File "/usr/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  3.     response = view_func(request, _args, *_kwargs)
    
    File "/usr/lib/python2.7/site-packages/rosetta/views.py" in home
  4.     return list_languages(request)
    
    File "/usr/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  5.             return view_func(request, _args, *_kwargs)
    
    File "/usr/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  6.     response = view_func(request, _args, *_kwargs)
    
    File "/usr/lib/python2.7/site-packages/rosetta/views.py" in list_languages
  7. ADMIN_MEDIA_PREFIX = settings.ADMIN_MEDIA_PREFIX
    
    File "/usr/lib/python2.7/site-packages/django/utils/functional.py" in inner
  8.     return func(self._wrapped, *args)
    

Exception Type: AttributeError at /rosetta/
Exception Value: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'

Option to hide file name & path - feature request

For security reason it would be great if there was an option to not display information about the file the string is used in. (both file & full path).

This would be useful if you deletage translating to some external company/translator.

Thanks

Language is duplicated in language selection

I have zh-cn in languages

LANGUAGES = (
    ('en', gettext('English')),
    ('zh-cn', gettext('Mandarin Chinese')),
)

In mac os file system is case insensitive and on the language selection page I'm getting two rows with files
/locale/zh_CN/LC_MESSAGES/django.po
/locale/zh_cn/LC_MESSAGES/django.po

rosetta doesn't find locales if project is a subdirectory

My strucure look like this:

  manage.py
  myapp/
    __init__.py
    models.py
  mysite/
    __init__.py
    settings.py
    urls.py

So rosetta doesn't find locales because:
abs_project_path is "/project_root_dir/mysite" and not "/project_root_dir/"

Working with virtualenv and django 1.4

changeable messages file name

The current code allows only 'django.po' files to be used, and as I found a way to use this helpful application in some non-fully django projects, it would be better if we could specify in our settings file at least for which filenames to look for.

Rosetta doesn't work with "feature url tag"

I use "url" tag from feature library - in my settings.py file, there is:

import django.template
django.template.add_to_builtins('django.templatetags.future')

... and then rosetta says:

TemplateSyntaxError at /rosetta/
Could not parse the remainder: '-pick-file' from 'rosetta-pick-file'

Fail on unicode appname.

I had this error thrown on rosetta/poutil.py line 76

app = getattr(import(appname[:p], {}, {}, [appname[p + 1:]]), appname[p + 1:])
TypeError: Item in ``from list'' not a string

I'm French and I use in my settings.py. I use python 2.7/2.6
from future import unicode_literals

I found how to fix it with this stackoverflow answer:
http://stackoverflow.com/a/2683624/267364

So, putting a b prefix to have non unicode appname look required for this application to work for python 2 when the rest of django's environnement is ok. maybe you may want to user an str cast on appname to fix it. (will work with both unicode and non unicode appname for python 2, and probably python 3 as import should take unicode literals.)

Tests modify global state (settings.LANGUAGES) and don't restore original state after run

This causes issues with test isolation - if I were to run my application's business test in the same run as rosetta's tests, I would have my application's tests failing that may rely on the settings.

The offending line is in RosettaTestCase.setUp (

settings.LANGUAGES = (('xx', 'dummy language'), ('fr_FR.utf8', 'French (France), UTF8'))
)

The way I usually address these issues is by storing the original value of the setting my tests modify, and then restore them in the tearDown method

Rosetta not finding locale pos in conf/locale

By default, Django will store the locale files in conf/locale.

But some reasons, Rosetta will not pick up those files, but rather only files in the app directories.

Any ideas why?

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.