gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 04:17:27 26 4
gpt4 key购买 nike

我不是 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com