从 resx 文件中读取资源
Read resources from a resx file
我已经为不同的语言定义了资源文件
- Resources.de-DE.resx
- Resources.en-US.resx
- Resources.es-ES.resx
- Resources.fr-FR.resx
- Resources.it-IT.resx
- Resources.nl-NL.resx
- Resources.resx
我正在尝试获取以下字符串的本地化值:"Notification created by {user.Name}"。
我尝试了很多方法来获取正确资源文件中指定的字符串,但它不起作用:它总是使用 Res 中指定的 "default" 字符串:
var resourceName = $"MyFunctionApp.Properties.Resources.{plant.LanguageCode}.resx";
var resourceSet = new ResourceSet(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName));
string createdBy = resourceSet.GetString(_notificationReportedBy);
甚至:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(plant.LanguageCode);
string longDescription = $"{Resources.NotificationReportedBy} {notificationReported.ValidatedBy }\n{notificationReported.LongDescription}";
也许 Azure Functions 没有正确支持资源文件?
Azure Functions 当前不支持资源文件。本 GitHub 期跟踪此类支持的讨论和实施:https://github.com/Azure/Azure-Functions/issues/581
我已经为不同的语言定义了资源文件 - Resources.de-DE.resx - Resources.en-US.resx - Resources.es-ES.resx - Resources.fr-FR.resx - Resources.it-IT.resx - Resources.nl-NL.resx - Resources.resx
我正在尝试获取以下字符串的本地化值:"Notification created by {user.Name}"。
我尝试了很多方法来获取正确资源文件中指定的字符串,但它不起作用:它总是使用 Res 中指定的 "default" 字符串:
var resourceName = $"MyFunctionApp.Properties.Resources.{plant.LanguageCode}.resx";
var resourceSet = new ResourceSet(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName));
string createdBy = resourceSet.GetString(_notificationReportedBy);
甚至:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(plant.LanguageCode);
string longDescription = $"{Resources.NotificationReportedBy} {notificationReported.ValidatedBy }\n{notificationReported.LongDescription}";
也许 Azure Functions 没有正确支持资源文件?
Azure Functions 当前不支持资源文件。本 GitHub 期跟踪此类支持的讨论和实施:https://github.com/Azure/Azure-Functions/issues/581