I am developing a SharePoint Online add-in in ASP.NET MVC 5. I have three resource files with three languages that I want CultureInfo
to read when the corresponding language code is returned from Shareoint. This is my code:
In the ActionResult Index:
var returnedLangCode= WorkPlanRepo.LangSettings();
if (returnedLangCode!= "")
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(returnedLangCode);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(returnedLangCode);
}
else
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
}
The method returning sharePoint Lang settings in my class workPlanRepo:
public string LangSettings()
{
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
var twoLetterLangName = currentCulture.TwoLetterISOLanguageName;
return twoLetterLangName;
}
I hev three Resource files, Default is English, then I have Swedish and Danish. All Resources are set to Public. In the view I reach for the resource file like this:
@Html.Label(CMP.ArbetsplanWeb.App_LocalResources.GlobalRes.ResetCalender ,new { @class = "btn btn-default", id = "clearCal" })
This is the errormessage:
When settting the CultureInfo error is returned. Wanted to insert img, but the upload tool dosen“t seem to work properly.
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "CMP.ArbetsplanWeb.App_LocalResources.GlobalRes.resources" was correctly embedded or linked into assembly "CMP.ArbetsplanWeb" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Line 75: public static string ResetCalender {
Line 76: get {
Line 77: return ResourceManager.GetString("ResetCalender", resourceCulture);
Line 78: }
Line 79: }
MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "CMP.ArbetsplanWeb.App_LocalResources.GlobalRes.resources" was correctly embedded or linked into assembly "CMP.ArbetsplanWeb" at compile time, or that all the satellite assemblies required are loadable and fully signed.] System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
I havent registerd anything in web.config
or Global.asax
. I now I must be doing something wrong. But cant figure out what. I found diffrent guides and docs on this but cant figure out how to useit properly.
Thanks for all the help!!