[英]How to handle localized content in ASP.NET Core?
what is the best way to store and display localized user-supplied content through models in ASP.Net Core so that your site can be multilingual?通过 ASP.Net Core 中的模型存储和显示本地化用户提供的内容以便您的站点可以使用多语言的最佳方法是什么? The ASP.NET localization guides show how to localize the static parts of a web site like labels and messages.
ASP.NET 本地化指南展示了如何本地化网站的静态部分,如标签和消息。
I'm looking for a way to be able to store localized user-supplied content in multiple languages, and display the correct language based on in the user's selection.我正在寻找一种方法,能够以多种语言存储本地化的用户提供的内容,并根据用户的选择显示正确的语言。 So if the language is set to Thai, the application displays the Thai versions of the content, such as product description in Thai.
因此,如果语言设置为泰语,应用程序会显示内容的泰语版本,例如泰语的产品描述。
Is there a way to do this in ASP.NET Core?有没有办法在 ASP.NET Core 中做到这一点?
nopCommerce provides this feature - you can add multiple languages and enter details for product, user, category models etc in all the languages that you've selected (see image). nopCommerce 提供此功能 - 您可以添加多种语言,并以您选择的所有语言输入产品、用户、类别模型等的详细信息(见图)。
nopCommerce bilingual model entry form nopCommerce 双语模型报名表
nopCommerce stores these localization features in a database table (LocalizedProperty) essentially as key-value pairs with foreign keys to determine the object it's tied to. nopCommerce 将这些本地化功能存储在数据库表 (LocalizedProperty) 中,本质上是作为键值对与外键来确定它所关联的对象。
nopCommerce LocalizedProperty table nopCommerce LocalizedProperty 表
How do you make the application serve the correct values from such a table depending on locale?您如何使应用程序根据区域设置从这样的表中提供正确的值?
You may follow this solution.您可以遵循此解决方案。 I suggest you have two tables.
我建议你有两张桌子。 One is for the master data, and the other is for localized data.
一个用于主数据,另一个用于本地化数据。 For example:
例如:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.