向django添加自定义语言

编程入门 行业动态 更新时间:2024-10-11 23:17:49
本文介绍了向django添加自定义语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在将我的网站翻译成欧盟的24种语言。这些包括Malti语言,没有列在django默认支持的语言中。

我想知道是否有一种方法可以将自定义语言添加到django所以它可以使用本机i18n url功能。

谢谢!

解决方案

  • 我找到了解决方案,你必须在/ django手动添加一个文件夹/ conf / locale /您需要的语言扩展名。实际上,您可以复制过去的en(英文)文件夹,并在缺少语言(在我的情况下为mt))中命名。

  • 在此文件夹中,您还可以编辑文件formats.py以本地化日期,数字等。

  • 重新启动django,您的语言将被本地支持。

  • I'm translating my website into the 24 languages of the European Union. These include the "Malti" language, that is not listed in django default supported languages.

    I would like to know if there is a way to add a custom language to django so it can work with the native i18n url function.

    Thanks!

    解决方案

  • I found the solution, you have to manually add a folder in /django/conf/locale/ with the language extension you want. Actually you can just copy past the en (english) folder and name it after the missing language (in my case mt).

  • In this folder you can also edit the file formats.py to localize the dates, numbers etc.

  • Restart django and your language will be natively supported.

  • 更多推荐

    向django添加自定义语言

    本文发布于:2023-11-06 03:48:09,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1562645.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:自定义   语言   django

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!