Ask Your Question
0

How to customize messages in django applications?

asked 2010-04-24 12:38:30 -0500

Evgeny gravatar image Evgeny flag of Chile
11009 50 84 182
http://askbot.org/

updated 2010-04-27 13:54:38 -0500

I would like to change messages in the internationalized django application - for example - instead of a phrase "Recent tags" I would like to simply have "Recent topics".

How can that be done without changing messages in the source code?

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2010-04-24 12:47:03 -0500

Evgeny gravatar image Evgeny flag of Chile
11009 50 84 182
http://askbot.org/

updated 2010-04-26 00:23:04 -0500

You can customize locale file, actually better make a copy of some pre-made localization in your native language (if available), then change string "translations".

For example copy standard english locale to a new one called en_bob and skin (this part is specific to askbot and possibly osqa):

cp -r locale/en locale/en_bob
cp -r forum/skins/default forum/skins/bob

In skins there is one file containing messages for javascript called media/js/com.cnprog.i18n.js. You can also instead of copying whole skin, just take that file alone into forum/skins/bob/media/js (directory structure is important, but empty directories are not necessary), after you make a copy - tweak the translation of interest.

Then edit file locale/en_bob/LC_MESSAGES/django.po to your needs, save it and run

python manage.py makemessages

What can be changed and how? Well, for example find an entry that looks like so:

msgid "Recent tags"
msgstr ""

and turn it into

msgid "Recent tags"
msgstr "Recent topics"

There are other things to keep in mind when working with localization files. They are (gradually being) described in the post about internationalization.

link publish delete flag offensive edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow
1 follower

subscribe to rss feed

Stats

Asked: 2010-04-24 12:38:30 -0500

Seen: 799 times

Last updated: Apr 27 '10