I’ve got my app localized (English and Spanish) except that not all strings are translated. This is the code I’m using and seems to work well.
public static string? TextOrNull(string? ResourceFile, string ResourceID, CultureInfo thisCulture)
{
string? txt = null;
try
{
if ((ResourceFile != null) && (ResourceID != null))
{
txt = GetResourceManager(ResourceFile)?.GetString(ResourceID, thisCulture);
if ((txt != null) && (txt.Equals(string.Empty)))
txt = null;
}
}
catch
{
txt = null;
}
return (txt);
}
I’d like to know if the string returned from GetString is from the resource file associated with the given culture. Specifically, if the given culture is ‘es-mx’ but there is no Spanish text, I get English (appropriate behavior). Is there a way to know when this happens?
Thanks
I’m a native English speaker developing a .NET Maui app using VS 2022 Community 64 bit edition – 17.10.1
I can’t find anything in the documentation nor any examples.