我不是 Python
方面的专家或 gettext utilities
.我有一个 Django 项目,其中应用程序中有几个模块。我需要单独维护 .po
将在时间部署中合并的每个模块的翻译文件。例如,有一个 Dictionary
django-cms-2
旁边的模块我想要不同的两个模块.po
文件(例如 dict.po
和 django-cms-master.po
)。然后,我将使用 msgmerge
和 compilemessages
来自 gettext
和 Django 创建最终的 django.mo
文件。有什么解决方案可以满足我的需要吗?
最佳答案
这是我将 locale/LOCALE_CODE/下的多个 .po 文件合并到 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
关于django - 在 Django 中管理单独的翻译文件 (.po),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3198691/