[Abp vNext 源码分析] - 21. 界面与文字的本地化 (5)

还是没有取得,最后会使用默认的区域文化信息匹配对应的本地化字符串,一般来说该值建议设置为 en。

protected virtual LocalizedString GetLocalizedStringOrNull(string name, string cultureName, bool tryDefaults = true) { //Try to get from original dictionary (with country code) var strOriginal = Resource.Contributors.GetOrNull(cultureName, name); if (strOriginal != null) { return strOriginal; } if (!tryDefaults) { return null; } //Try to get from same language dictionary (without country code) if (cultureName.Contains("-")) //Example: "tr-TR" (length=5) { var strLang = Resource.Contributors.GetOrNull(CultureHelper.GetBaseCultureName(cultureName), name); if (strLang != null) { return strLang; } } //Try to get from default language if (!Resource.DefaultCultureName.IsNullOrEmpty()) { var strDefault = Resource.Contributors.GetOrNull(Resource.DefaultCultureName, name); if (strDefault != null) { return strDefault; } } //Not found return null; } 三、总结

点击我跳转到总目录

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpzssf.html