i'm trying to use the TranslateExtension method that is explained in the xaml Localization guide for xamarin forms. however i'm getting an error.
Unhandled Exception:
System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "CashRegisterApp.Resx.AppResources.resources" was correctly embedded or linked into assembly "CashRegisterApp.Android" at compile time, or that all the satellite assemblies required are loadable and fully signed. occurred
after debugging i noticed that the extension for the resource files is set to .resources for some reason. since this is not a public member of the resource manager i'm not sure on how i can set it to use resx or resw files.
You need to specify the current culture for your Resources
.
var culture = "en-US";
AppResources.Culture = new System.Globalization.CultureInfo(culture);
A .resx resource string value in the current assembly from a .resx file in a namespace with name MyNamespace
, path Resx\\Resources.resx
and resource name Key
can be read with the following. Note that no locale is defined:
string resourcesValue = MyNamespace.Resx.Resources.Key;
Using System.Resources.ResourceManager
, as in the localization example:
const string ResourceId = "MyAssembly.Resx.Resources";
private static readonly Lazy<ResourceManager> ResMgr = new Lazy<ResourceManager>(()
=> new ResourceManager(ResourceId, typeof(MyClass).GetTypeInfo().Assembly));
...
string resMgrValue = ResMgr.Value.GetString("Key");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.