开发者

Manage separate translation files (.po) in Django

开发者 https://www.devze.com 2023-01-05 21:39 出处:网络
I am not an expert in Python or gettext utilities. I have a Django project in which I have several modules in the application. I need to maintain separate .po translation files for each module that wi

I am not an expert in Python or gettext utilities. I have a Django project in which I have several modules in the application. I need to maintain separate .po translation files for each module that will be merged in the time deployment. For instance, there is a Dictionary module beside the django-cms-2 module for both of which I want to have different .po files (such as dict.po and django-cms-master.po). Then, I will use msgmerge and compilemessages from gettext and Django to create the final django.mo file. Is there any solution for what I need?开发者_StackOverflow中文版


Here's my quick hack to merge multiple .po-files under locale/LOCALE_CODE/ into locale/LOCALE_CODE/LC_MESSAGES/django.po

#!/bin/bash

# quick hack to merge all .po-files found under ./locale/LOCALE/
# to a django.po-file and then compile the django.po to django.mo

for l in locale/*
do
    bn=$(basename $l)
    echo "translating locale $bn"
    cat $l/*.po > $l/LC_MESSAGES/django.po
    python manage.py compilemessages -l $bn
done
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号