-EDIT 2- Figured it out, check my answer. I should stop asking questions on StackOverflow, I always figure it out a couple of minutes later 🙂
I have the following code (well, roughly, with detection and everything at top):
Manager = new ResourceManager("EM250.Localization.Application",
Assembly.GetExecutingAssembly());
// CurrentCulture being fr-CA in this case
return Manager.GetString(Key, CurrentCulture);
So, I manage my localization resources using a custom class I made.
I got two files, one called “Application.resx” and another, “Application.fr-CA.resx”. Both are set to “Embedded Resource”. When I compile my code, I get a folder called “fr-CA” with the file “Library.resources.dll” in it. Which is completely fine.
Anyone has an idea why my code is not working? I get English strings everywhere.
Note that is not an ASP.NET project but an actual WinForms project.
-EDIT- Should probably post the rest of the code this is the initialization of my Application:
String LocaleLoad;
if(Configuration.GetString("Language") == null)
{
// Detect which if the computer is set in french.
switch(System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName)
{
case "fr":
LocaleLoad = "fr-CA";
break;
default:
LocaleLoad = "en-CA";
break;
}
}
else
{
LocaleLoad = Configuration.GetString("Language");
}
// Initialize the localization class.
Localization.Initialize(LocaleLoad);
And this is my Localization class:
/// <summary>
/// Initialize the culture info with the specific culture.
/// </summary>
/// <param name="Culture">The culture to load.</param>
public static void Initialize(string Culture)
{
CultureInfo NewCulture = new CultureInfo(Culture);
if(!(Localization.CurrentCulture == null || CurrentCulture.TwoLetterISOLanguageName == NewCulture.TwoLetterISOLanguageName))
{
CurrentCulture = NewCulture;
Thread.CurrentThread.CurrentCulture = NewCulture;
Thread.CurrentThread.CurrentUICulture = NewCulture;
OnCultureChanged();
}
Thread.CurrentThread.CurrentCulture = NewCulture;
Thread.CurrentThread.CurrentUICulture = NewCulture;
CurrentCulture = NewCulture;
foreach(Language Lang in ListLanguages)
{
if(Lang.DisplayName == CurrentCulture.NativeName)
{
CurrentLanguageValue = Lang;
}
}
Manager = new ResourceManager("EM250.Localization.Application", Assembly.GetExecutingAssembly());
}
/// <summary>
/// Get a single entry from the ressource file.
/// </summary>
/// <param name="Key">The value to get from the ressource file.</param>
public static string GetString(string Key)
{
return Manager.GetString(Key, CurrentCulture);
}
My Ressource ID wasn’t set properly for my fr-CA file. My en-CA file was set to “EM250.Localization.Application.resources” and the fr-CA was “Library.Localization.Application.fr-CA.resources”