从resx文件中读取资源

时间:2018-03-06 10:38:22

标签: azure azure-functions localizable.strings

我已为不同语言定义了资源文件 - 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

我试图获取以下字符串的本地化值:" {user.Name}创建的通知"。

我已经尝试了很多东西来获取正确的资源文件中指定的字符串,但它不起作用:它始终采用"默认" Res:

中指定的字符串
    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功能不能正确支持资源文件?

1 个答案:

答案 0 :(得分:0)

Azure功能当前不支持资源文件。此GitHub问题跟踪此类支持的讨论和实施:https://github.com/Azure/Azure-Functions/issues/581