django - 在 Django 中管理单独的翻译文件 (.po)

标签 django internationalization translation gettext

我不是 Python 方面的专家或 gettext utilities .我有一个 Django 项目,其中应用程序中有几个模块。我需要单独维护 .po将在时间部署中合并的每个模块的翻译文件。例如,有一个 Dictionary django-cms-2 旁边的模块我想要不同的两个模块.po文件(例如 dict.podjango-cms-master.po )。然后,我将使用 msgmergecompilemessages来自 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/

相关文章:

python - __init__() 在 django 中遇到意外的关键字参数 'status' 错误

android - 在 Android 中与远程服务器进行数据交换

python - Django Rest - 在 get_*** 方法中包含序列化器对象

Spring本地化消息持久化

iOS:当我尝试使用西方字体显示日语字符时,如何找出使用的 "fallback font"?

c# - 旋转和平移对象

python - Django - 存储过程不存在

php - 是否可以将 unicode 数字与 mysql int 列进行比较?

forms - 翻译Flash消息

api - REST 风格的 API : How to handle translated textfields in representations?