I finished a few days ago, creating a translation file for Django-LFS (Lightning Fast Shop) for my native language (pt_BR). Now that it's done, I need to install the ".po" file that I downloaded after finishing my translation in Transifex.
Ok, I downloaded the file, but now that I need to install it, I just can't figure how. I tried putting the file in 'lfs-installer' folder, using "bin/django compilemessages -a", tried the same thing but with the file in many different folders, but I just can't make my LFS use my translation file...
Does anyone know how to make a translation package work on lfs? Or am I doing something wrong?
T开发者_运维知识库hanks
put you .po file in the path:
<your_django_project>/conf/locale/pt_BR/LC_MESSAGES/
and run django-admin makemessages -a
If you do not already have one, create a folder called Locale. Then in your settings.py folder you must tell it where to find the locale paths. Something like this:
LOCALE_PATHS{
C:/sdalfjasd/dfalsdjkf/locale
}
Also make sure you have locale middleware in your middleware...
You can probably effectively track down that syntax and specifics, now that I pointed you in the right direction.
Once you have those things set up, you can run your makemessage -a
command, which will create a folder in your locale folder for the -a you put in. Then you can browse to this, inside it there should be a .po file (there might not be). If there is not, just put your .po file you made in there.
Then browse to your project in your CMD, and run compilemessages -a
. This should compile your .po files into .mo files, the files necessary for translations to work.
Hopefully I did not go crazy off-track...
I made it to work using the following settings:
import os
DIRNAME = os.path.dirname(__file__)
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'pt-br'
LANGUAGES = (
('pt-br', u"Português"),
)
LOCALE_PATHS = [
DIRNAME + '/locale',
]
Than create a locale
folder aside of the settings.py folder and follow Django official instructions. The desired path for your django.po
file is: locale/pt_BR/LC_MESSAGES/django.po
. After that, use compilemessages
tool and restart the server.
It should work.
Tip: django-lfs uses locale
module to handle currency display, but there is a bug for locale module that makes it to show 1234,00 R$
instead of R$ 1234,00
. If it bites you, put the following into your settings.py
:
# Fix for LC_MONETARY bug: http://www.sourceware.org/bugzilla/show_bug.cgi?id=1294
import locale
locale._override_localeconv.update({'p_cs_precedes': 1, 'n_cs_precedes': 1})
Good luck.
精彩评论