0
1

I finally installed rosetta, but in my "OSQA Project" directory

/opt/OSQA/locale/

I find only the following languages:

/opt/OSQA/locale/bg/LC_MESSAGES/django.po
/opt/OSQA/locale/de/LC_MESSAGES/django.po 
/opt/OSQA/locale/en/LC_MESSAGES/django.po 
/opt/OSQA/locale/es/LC_MESSAGES/django.po 
/opt/OSQA/locale/fr/LC_MESSAGES/django.po 
/opt/OSQA/locale/pt/LC_MESSAGES/django.po 
/opt/OSQA/locale/zh_CN/LC_MESSAGES/django.po

In my python dir I have an Italian dir

/opt/ActivePython-2.7/lib/python2.7/site-packages/django/conf/locale/it/LC_MESSAGES

with the following files inside

djangojs.mo
djangojs.po
django.mo
django.po

But they contain translation for django admin interface itself and I don't understand what I've to do in order to "istall" the it language pack into OSQA

asked 08 Feb, 09:13

bosch's gravatar image

bosch
196512
accept rate: 20%


This post regards the installation & configuration of rosetta on BITNAMi OSQA stack (osqa-1.0rc-0) on MacOSX 10.7 (Lion) but I think this could work fine on other Linux based OSs.

bash-3.2$ cd /Applications/osqa-1.0rc-0/

set environment variables executing the following script:

bash-3.2$ ./use_osqa

now install django-rosetta package using "easy_install" and not "pip" (not included in python distro of BITNAMI osqa stack)

bash-3.2$ easy_install django-rosetta
Searching for django-rosetta
Reading http://pypi.python.org/simple/django-rosetta/
Reading http://code.google.com/p/django-rosetta/
Reading https://github.com/mbi/django-rosetta
Best match: django-rosetta 0.6.5
Downloading http://pypi.python.org/packages/source/d/django-rosetta/django-rosetta-0.6.5.zip#md5=dcd435b29c6decf17e0e5a9cb96f00da
Processing django-rosetta-0.6.5.zip
Running django-rosetta-0.6.5/setup.py -q bdist_egg --dist-dir /var/folders/t_/rv67w88j3z9c70ql0y5gzbz80000gn/T/easy_install-ED6ePG/django-rosetta-0.6.5/egg-dist-tmp-TGMr0I
Adding django-rosetta 0.6.5 to easy-install.pth file

Installed /Applications/osqa-1.0rc-0/python/lib/python2.6/site-packages/django_rosetta-0.6.5-py2.6.egg
Processing dependencies for django-rosetta
Finished processing dependencies for django-rosetta

Enter the OSQA dir and execute django-admin.py script

bash-3.2$ cd /Applications/osqa-1.0rc-0/apps/osqa
bash-3.2$ /Applications/osqa-1.0rc-0/apps/django/bin/django-admin.py makemessages -a

on MacOSX: If you obtain the following error

processing language it
Error: errors happened while running xgettext on __init__.py
/bin/sh: xgettext: command not found

Download & Install gettext.pkg compiled for your specific OS version

If you obtain the following errror:

processing language it
Traceback (most recent call last):
  File "/Applications/osqa-1.0rc-0/apps/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
    utility.execute()
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/commands/makemessages.py", line 365, in handle_noargs
    make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_obsolete)
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/core/management/commands/makemessages.py", line 233, in make_messages
    f.write(templatize(src, orig_file[2:]))
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/utils/translation/__init__.py", line 127, in templatize
    return _trans.templatize(src, origin)
  File "/Applications/osqa-1.0rc-0/apps/django/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 450, in templatize
    content = u''.join(comment)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 181: ordinal not in range(128)

Follow the instructions here to fix it:

bash-3.2$ vim ./apps/django/lib/python2.6/site-packages/django/utils/translation/trans_real.py

and apply changes

Finally execute again:

bash-3.2$ /Applications/osqa-1.0rc-0/apps/django/bin/django-admin.py makemessages -a
processing language bg
processing language de
processing language en
processing language es
processing language fr
processing language it
processing language ja
processing language l
processing language pt
processing language zh_CN

Now you'll have django.po files in your "locale" dir. For italian language this should be the path:

/Applications/osqa-1.0rc-0/apps/osqa/locale/it/LC_MESSAGES/django.po

Edit OSQA settings_local.py file updating LANGUAGE_CODE value

bash-3.2$ vim /Applications/osqa-1.0rc-0/apps/osqa/setting_local.py
LANGUAGE_CODE = 'it'

Restart Apache

bash-3.2$ /Applications/osqa-1.0rc-0/ctlscript.sh restart apache

Go to 'nimda' page (pay attention, you have to add /osqa/ into the context URL )

http://server:port/osqa/nimda/

Login as a local admin usr/pwd (NO LDAP user, NO OpenId credential, just a superuser account stored in your OSQA db)

Switch to 'rosetta' page

http://server:port/osqa/rosetta/

Select your language under "Project" tab

Start Translating!

link

answered 20 Feb, 06:51

bosch's gravatar image

bosch
196512
accept rate: 20%

Thank you bosch, you really did something that I hope is going to be helpful to many others as well, beside myself. And I'm grateful to you. The bad thing is that I'm using windows xp, but for this purpose since I cannot find any tutorials on this topic, I may install Lion. I think that when I finish translation I'll could use it with windows too. Or I'm wrong? Thank you! (sorry for delay but my comments still must go through moderation)

(20 Feb, 08:13) balbao
1

I'm not sure it's gonna work if you simply copy-paste the django.po file from MacOSX to WinXP... but I think you can reproduce these steps using the same commands on WinXP

For instance you can find the easy_install.exe binary at C:\Program Files\BitNami OSQA Stack\python\scripts folder

(20 Feb, 10:27) bosch

I finally found a solution by myself putting together the pieces of the puzzle...

I post here the steps I followed hoping this could help someone else not to do the same effort I did

This would work with every language (non only italian)

Installing & Configuring ROSETTA

Follow developer's instructions here

pip install django-rosetta

Create a new language pack in OSQA

[root@server OSQA]# /opt/ActivePython-2.7/bin/django-admin.py makemessages -l it -e html,txt -e xml

Where 'it' stands for ITALIAN

Probably you'll receive the following error

processing language it
Error: errors happened while running xgettext on commands.py
./forum/views/commands.py:585: warning: 'msgid' format string with unnamed arguments cannot be properly localized:
                                        The translator cannot reorder the arguments.
                                        Please consider using a format string with named arguments,
                                        and a mapping instead of a tuple for the arguments.

Don't panic, if you'have installed and configured OSQA so far, you're already accustomed to pain... : )

To solve the problem, just apply the fix here

[root@server OSQA]# vim forum/views/commands.py

replace line 585 with following line:

return { 'message' : _("You have awarded %(awarded_user)s with %(points)d points") % {'awarded_user' : awarded_user, 'points' : points} }

let's go ahead with the build of the language pack

[root@server OSQA]# /opt/ActivePython-2.7/bin/django-admin.py makemessages -d django -l it
[root@server OSQA]# /opt/ActivePython-2.7/bin/django-admin.py makemessages -d djangojs -l it
[root@server OSQA]# /opt/ActivePython-2.7/bin/django-admin.py makemessages -a

This will create a folder 'it' under 'locale' dir in your OSQA containing LC_MESSAGES/django.po file

In my case:

/opt/OSQA/locale/it/LC_MESSAGES/django.po

Activate language pack

Edit the owner of 'it' dir

[root@server OSQA]# chown -R apache:apache /opt/OSQA/locale/it/

Edit OSQA settings_local.py file updating LANGUAGE_CODE value

[root@server OSQA]# vim settings_local.py
LANGUAGE_CODE = 'it'

Restart Apache

[root@server OSQA]# service httpd restart

Go to 'nimda' page (this was the more tricky part...)

http://server:port/nimda/

Login as a local admin usr/pwd (NO LDAP user, NO OpenId credential, just a superuser account stored in your OSQA db)

Switch to 'rosetta' page

http://server:port/rosetta/

Select your language under "Project" tab

Start Translating!

PS: If you see a broken-style django admin interface, it's because you missed this Apache Alias configuration

link

answered 08 Feb, 14:35

bosch's gravatar image

bosch
196512
accept rate: 20%

Thank you very much for this instructions. If you could just add few more steps (for us which are newbie to django/phyton), I mean where do I type this commands, I installed OSQA with bitnami and when I download rosetta (as zip)where and in which format shell I save it? if you could answer me I would be grateful, thank you for help

(19 Feb, 10:46) balbao

Hi balbao, the installation & configuration process of rosetta on Bitnami stack is a little bit simpler, because it's based on a newer release of django 1.3 instead o 1.2.7 that I used in my native installation from scratch. Try to follow the steps in the following answer

(20 Feb, 06:17) bosch
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30
×22
×12
×1

Asked: 08 Feb, 09:13

Seen: 406 times

Last updated: 20 Feb, 10:27

powered by OSQA