本地化:django-admin编译消息跳过venv [英] Localization: django-admin compilemessages skip venv

查看:151
本文介绍了本地化:django-admin编译消息跳过venv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Django 1.11 应用程序中使用本地化。我可以排除虚拟环境文件夹和 node_modules 文件夹,而使用 -i 选项在消息文件中添加消息,例如:

I am using localization in Django 1.11 application. I can exclude the virtual environment folder and node_modules folder while adding the messages in message file using -i option like:

django-admin makemessages -l 'no' -i venv
django-admin makemessages -d djangojs --locale no -i venv -i node_modules

添加翻译后,我使用以下命令编译消息:

After adding the translations I am compiling messages using:

django-admin compilemessages

它处理位于虚拟环境文件夹中的所有已安装软件包的 django.po 文件。因此,完成翻译需要更长的时间。

It processes django.po files of all installed packages located in virtual environment folder. Thus it takes longer time to finish compiling translations.

我没有找到任何参数参数来跳过 compilemessages 文档中的c>命令。

I did not find any argument parameter to skip a specific path from compilemessages command in documentation.

是否可以从 compilemessages venv 或特定路径? c $ c>?

Is there any option to skip the venv or specific path from compilemessages?

推荐答案

我想知道该静脉的最好之处是:

THE BEST HACK I FOUND TO IGNORE THE VENV IS:

cd to project
python ../manage.py makemessages  (jumping one directory up)
python ../manage.py compilemessages

(来自同事的这个小技巧可避免编译venv .po)

(This little hack from a workmate avoids compiling the venv .po)

(方法2)

在此之前,我尝试使用-exclude 标志

Before that, I was trying the more complicated way of using the --exclude flag

usage: django-admin compilemessages [-h] [--version] [-v {0,1,2,3}]
                                    [--settings SETTINGS]
                                    [--pythonpath PYTHONPATH] [--traceback]
                                    [--no-color] [--locale LOCALE]
                                    [--exclude EXCLUDE] [--use-fuzzy]

github

        parser.add_argument(
            '--exclude', '-x', action='append', default=[],
            help='Locales to exclude. Default is none. Can be used multiple times.',
        )

不幸的是,这是针对区域设置的,但是它是到目前为止我发现的唯一内容

Unfortunately this is for locales, but it is the only thing I found so far

来自关于Django开发的这些内部通讯,我可以看到ignore标志已从makemessages复制到了compilemessages以用于将来的版本

From these internal communications on the development of Django, I can see the ignore flag has been copied from makemessages to compilemessages for a future version

我使用了(不包括es和en)

For my own usage I used (excluding es and en)

django-admin compilemessages --exclude=sw --exclude=sl --exclude=sk --exclude=km --exclude=sv --exclude=ko --exclude=sq --exclude=sr --exclude=kk --exclude=ka --exclude=es_MX --exclude=fa --exclude=fy --exclude=fr --exclude=en_AU --exclude=ne --exclude=nb --exclude=nn --exclude=nl --exclude=id --exclude=az --exclude=io --exclude=ar --exclude=ia --exclude=kn --exclude=it --exclude=is --exclude=vi --exclude=af --exclude=my --exclude=mr --exclude=uk --exclude=pl --exclude=ur --exclude=mk --exclude=mn --exclude=ml --exclude=he --exclude=hi --exclude=hu --exclude=hr --exclude=en_GB --exclude=pa --exclude=cs --exclude=fi --exclude=cy --exclude=sr_Latn --exclude=os --exclude=pt --exclude=ja --exclude=bs --exclude=br --exclude=bn --exclude=ast --exclude=bg --exclude=hsb --exclude=dsb --exclude=ro --exclude=es_CO --exclude=ru --exclude=et --exclude=eu --exclude=zh_Hant --exclude=zh_Hans --exclude=be --exclude=eo --exclude=el --exclude=da --exclude=de --exclude=pt_BR --exclude=ta --exclude=ca --exclude=te --exclude=es_AR --exclude=th --exclude=lt --exclude=lv --exclude=tr --exclude=tt --exclude=es_VE --exclude=lb --exclude=gl --exclude=ga --exclude=gd --exclude=udm--exclude=sw --exclude=sl --exclude=sk --exclude=km --exclude=sv --exclude=ko --exclude=sq --exclude=sr --exclude=kk --exclude=ka --exclude=es_MX --exclude=fa --exclude=fy --exclude=fr --exclude=en_AU --exclude=ne --exclude=nb --exclude=nn --exclude=nl --exclude=id --exclude=az --exclude=io --exclude=ar --exclude=ia --exclude=kn --exclude=it --exclude=is --exclude=vi --exclude=af --exclude=my --exclude=mr --exclude=uk --exclude=pl --exclude=ur --exclude=mk --exclude=mn --exclude=ml --exclude=he --exclude=hi --exclude=hu --exclude=hr --exclude=en_GB --exclude=pa --exclude=cs --exclude=fi --exclude=cy --exclude=sr_Latn --exclude=os --exclude=pt --exclude=ja --exclude=bs --exclude=br --exclude=bn --exclude=ast --exclude=bg --exclude=hsb --exclude=dsb --exclude=ro --exclude=es_CO --exclude=ru --exclude=et --exclude=eu --exclude=zh_Hant --exclude=zh_Hans --exclude=be --exclude=eo --exclude=el --exclude=da --exclude=de --exclude=pt_BR --exclude=ta --exclude=ca --exclude=te --exclude=es_AR --exclude=th --exclude=lt --exclude=lv --exclude=tr --exclude=tt --exclude=es_VE --exclude=lb --exclude=gl --exclude=ga --exclude=gd --exclude=udm --exclude=zh_CN  --exclude=ky --exclude=zh_TW --exclude=no --exclude=pt_PT  --exclude=hy

这篇关于本地化:django-admin编译消息跳过venv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆