博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
django-filer中文汉化无效的解决方案
阅读量:6857 次
发布时间:2019-06-26

本文共 1064 字,大约阅读时间需要 3 分钟。

最近在django项目中使用django-filer管理后台文件,就算我把django的setting中额语言设置成为了LANGUAGE_CODE = 'zh-Hans',页面仍然汉化无效。我在django-filer的依赖安装目录页发现了zh-Hans的翻译包。

根据博客https://stackoverflow.com/questions/12101811/trans-string-not-working-on-templates-but-trans-variable-does/12223367我找到了django拉取翻译包的代码。

def to_locale(language):    """Turn a language name (en-us) into a locale name (en_US)."""    language, _, country = language.lower().partition('-')    if not country:        return language    # A language with > 2 characters after the dash only has its first    # character after the dash capitalized; e.g. sr-latn becomes sr_Latn.    # A language with 2 characters after the dash has both characters    # capitalized; e.g. en-us becomes en_US.    country, _, tail = country.partition('-')    country = country.title() if len(country) > 2 else country.upper()    if tail:        country += '-' + tail    return language + '_' + country

  实际上,LANGUAGE_CODE = 'zh-Hans',拉取的是zh_Hans包里面的翻译内容,但是django-filer的翻译包的中文目录名称是zh-Hans,修改名称后果然解决问题

转载于:https://www.cnblogs.com/dongqiSilent/p/10848106.html

你可能感兴趣的文章
windows 屏幕坐标 窗口坐标 客户区坐标 逻辑坐标 设备坐标之间的关系及转换
查看>>
在Foreda8上试安装Apchehttpd-2.4.6.tar.gz
查看>>
基于S3C2410的VIVI移植
查看>>
Entity Framwork one to one problem
查看>>
[转] Attach、Detach和DeleteObject
查看>>
[转] C# 获取程序运行目录
查看>>
【OpenCV学习】极坐标变换
查看>>
使用open***构建安全***
查看>>
模仿支付宝支付密码框思路
查看>>
docker 容器的网络配置
查看>>
开源监控软件的配置:cacti,nagios
查看>>
Python多线程之threading模块
查看>>
第 6 章 单区域 OSPF
查看>>
Android图片开发内幕--基础篇
查看>>
LVS DR模式
查看>>
ZooKeeper 的安装 以及配置说明
查看>>
iOS10推送通知(本地&远程)/Swift
查看>>
标准交互及UED、埋点及锚应用、外部调用原则。请教一下哪位大佬知道这三个的应用?求助...
查看>>
浅入深谈:一道Python面试题,让我明白了殊途同归,却开始怀疑自己
查看>>
内存时序对应的4个参数你们知道吗?ICMAX一文让你看懂
查看>>