如何本地化 Django 应用程序的内容

How to localize Content of a Django application(如何本地化 Django 应用程序的内容)
本文介绍了如何本地化 Django 应用程序的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

嘿,我目前正在为我的学习开发一个 django 应用程序,并达到了 l18n 的地步.本地化网站本身非常容易,但现在我必须允许用户翻译应用程序的动态内容.用户可以将产品"保存在数据库中并为其命名和描述,但由于整个站点都应该本地化,我必须提供一种将这些名称和描述翻译给用户的方法.

Hey, i am currently working on a django app for my studies, and came to the point of l18n. Localizing the site itself was very easy, but now i have to allow users, to translate the dynamic content of the application. Users can save "products" in the database and give them names and descriptions, but since the whole site should be localized, i must provide a way of translating theses names and descriptions to the users.

在 django 中有一种自然的方式来做到这一点吗?还是我必须将其作为应用程序的一部分来实现(通过在数据模型中表示翻译)

Is there a natural way in django to do this? Or do i have to realize it as part of the application (by representing the translations in the datamodel)

谢谢,亚诺施

推荐答案

我建议查看 django-多语言.它是一个第三方应用程序,可让您在模型上定义翻译字段.

I would suggest checking out django-multilingual. It is a third party app that lets you define translation fields on your models.

当然,您仍然需要输入实际的翻译,但它们会透明地存储在数据库中(与静态 PO 文件相反),我相信这就是您要问的问题.

Of course, you still have to type in the actual translations, but they are stored transparently in the database (as opposed to in static PO files), which is what I believe you are asking about.

这篇关于如何本地化 Django 应用程序的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Seasonal Decomposition of Time Series by Loess with Python(Loess 用 Python 对时间序列进行季节性分解)
Resample a time series with the index of another time series(使用另一个时间序列的索引重新采样一个时间序列)
How can I simply calculate the rolling/moving variance of a time series in python?(如何在 python 中简单地计算时间序列的滚动/移动方差?)
How to use Dynamic Time warping with kNN in python(如何在python中使用动态时间扭曲和kNN)
Keras LSTM: a time-series multi-step multi-features forecasting - poor results(Keras LSTM:时间序列多步多特征预测 - 结果不佳)
Python pandas time series interpolation and regularization(Python pandas 时间序列插值和正则化)