更新时间:2023-01-01 21:03:50
Ok, I found how to do this and with a sample project found here
Basically the implementation is the following:
现在在您的ClassLibrary中添加一个具有以下代码(适用于您的项目)的新类:
Now add a new Class in your ClassLibrary that has the following code(adapted to your project):
using System;
using Windows.ApplicationModel.Resources;
namespace MyClassLibraryName.Tools {
public static class LocalizationTool {
static ResourceLoader resourceLoader = null;
public static string MyStringOne {
get {
String name;
GetLibraryName("MyStringOne", out name);
return name;
}
}
private static void GetLibraryName(string resourceName, out string resourceValue) {
if(resourceLoader == null) {
resourceLoader = ResourceLoader.GetForCurrentView("MyClassLibraryName/Resources");
}
resourceValue = resourceLoader.GetString(resourceName);
}
}
}
在您的ClassLibrary或MainApp中,只需调用以下内容:
And in your ClassLibrary or MainApp just call the following:
string text = LocalizationTool.MyStringOne;