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.
Rosetta is a Django application that eases the translation process of your Django projects
License: MIT License
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.
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?
it seems that it is reading/writing the .po file anyways. Would it be a bad idea to let Rosetta add new terms?
It would be nice if one could control rosetta with keyboard shortcuts...
examples:
I have a PO directory called en_US. In the admin panel, rosetta displays both en_US and en_us. Only editing en_us does any actual updates to the translation files.
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
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)?
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.
Using django 1.4 rosetta raises
AttributeError at /rosetta/
'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'
ADMIN_MEDIA_PREFIX is now deprecated due to https://docs.djangoproject.com/en/dev/releases/1.4/#django-contrib-admin
There should be button or something to copy translation from original - something that poeditor does have
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
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?
To reproduce this issue:
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
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:
Or place a
below the toolbar
Thanks for the great app!!
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.
It would be really nice if we could add some JavaScript (probably?) to un-check the fuzzy flag, when a translation changes.
We found some of our users forget to do this otherwise.
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.
Is there any chance to reload translation with gunicorn?
Something similar to ROSETTA_WSGI_AUTO_RELOAD and ROSETTA_UWSGI_AUTO_RELOAD.
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.)
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 (
django-rosetta/rosetta/tests/__init__.py
Line 53 in 44b3314
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
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)
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
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
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.
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
response = callback(request, _callback_args, *_callback_kwargs)
return view_func(request, _args, *_kwargs)
response = view_func(request, _args, *_kwargs)
return list_languages(request)
return view_func(request, _args, *_kwargs)
response = view_func(request, _args, *_kwargs)
ADMIN_MEDIA_PREFIX = settings.ADMIN_MEDIA_PREFIX
return func(self._wrapped, *args)
Exception Type: AttributeError at /rosetta/
Exception Value: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'
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
PyPI has 0.6.8 which doesn't work with Django 1.5. Please upload 0.7.0 to PyPI.
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 :)
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/
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
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?
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.
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?
Rosetta only allows the editing of django.po and djangojs.po. But it would be nice to allow the user to override this and load any kind of file in Rosetta e.g. example.po.
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 :)
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
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!".
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"
The "Suggestion" links within Rosetta no longer work. When the user clicks on a Suggestion link, the text "Please use Translate v2. See http://code.google.com/apis/language/translate/overview.html" appears below the item the user attempted to translate.
This is because the Google Translate API v1 has been deprecated. Version 2 is paid-only so something other than the google translate api must be used.
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
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.
For example, Russian has three forms, however Rosetta fails to display input fields for all of them -- only two are shown. Even Rosetta's own translation has only two forms instead of three (https://github.com/mbi/django-rosetta/blob/develop/rosetta/locale/ru/LC_MESSAGES/django.po).
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?
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?
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:
Configuration:
ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage'
SESSION_COOKIE_SECURE = False
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'dwight-dev',
}
}
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.
task:
user has to edit translations without access to admin interface
problem:
user has to be marked as superuser and staff ( http://code.google.com/p/django-rosetta/issues/detail?id=92 ), but this also grants user an access to admin interface. adding to group "translators" doesn't work as well
there is a {% ifequal rosetta_i18n_catalog_filter 'something' %} in languages.html template, but the variable is not defined in the context, so the active button highlight doesn't work.
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?
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'
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.