ResourceLoader returns 空字符串

ResourceLoader returns empty strings

我正在尝试在我的 UWP 应用程序中使用 *.resw 文件来存储本地化字符串。我正在通过 ResourceLoader.GetString() 加载这些字符串,并将它们放在 MessageDialog 中以呈现给用户,但无论我做什么, GetString() 的 return 值都是空的(零长度)字符串。我正在关注 SDK sample for localization,但没有收到预期的回复。

我尝试使用的字符串格式为 InvalidAssemblyDialog.Message.

事实证明,这个问题是由于我在 *.resw 文件中的字符串的键中使用了点。点是保留的,我对它们的使用导致了名称解析错误。在上面的示例中,我将其更改为 InvalidAssemblyDialog_Message.

Here 文档说“。”从代码中查询资源时,字符应替换为“/”。

If a resource name is segmented (it contains "." characters), then replace dots with forward slash ("/") characters in the resource name. Property identifiers, for example, contain dots; so you'd need to do this substition in order to load one of those from code.