【发布时间】:2017-07-04 20:40:44
【问题描述】:
使用 nopCommerce 3.9 如果我只知道语言文化,如何找出语言的 LanguageId(存储在 nopCommerce 数据库中的 ID)?
例如,当我想在插件的Install() 方法中添加语言环境资源时,我可以通过将文化指定为字符串值来实现
this.AddOrUpdatePluginLocaleResource("Plugins.Payment.CheckMoneyOrder.AdditionalFee",
"Additional fee", "en-US");
但其他方法需要语言 ID 并且不接受文化字符串。 (例如设置的SaveLocalizedSetting扩展方法)
checkMoneyOrderPaymentSettings.SaveLocalizedSetting(x => x.DescriptionText,
languageId, //how to find out the ID for "en-US"
"my localized text");
如果我只知道执行时的语言环境资源,如何获取“en-US”的 ID?
【问题讨论】:
-
什么语言 ID?你的意思是
CultureInfo.GetCultureInfo("en-US").LCID还是类似的? -
存储在 nopCommerce 数据库中的语言 ID(我更新了我的问题)
-
为什么你不这样做,就像 nopCommerce 那样? checkMoneyOrderPaymentSettings.SaveLocalizedSetting(x => x.DescriptionText,localized.LanguageId,localized.DescriptionText);
-
@Tomu 因为我想在插件的
Install()method 中做到这一点。我没有localized实例,但有多种文化(“en-US”、“de-DE”等)
标签: c# nopcommerce