I am working on a project in MVC5 Razor which utilizes localization. However not all strings are localized. Even on the same page some will be localized (in Swedish in this case) and others aren't. For instance an actionlink like this:
@Html.ActionLink(@Resources.MyProject.UI_NewFAQuestion, "Create", new { returnUrl = Request.Url.AbsoluteUri })
I've tried this variant as well that I read somewhere was necessary, but it shows the english (default) string as well:
@Html.Raw(string.Format("{0}", Html.ActionLink(@Resources.MyProject.UI_NewFAQuestion, "Create", new { returnUrl = Request.Url.AbsoluteUri })))
@Resources.MyProject.[Resource Name]
will show in English (default language) regardless, but calls to
@Html.LabelFor()
will use the localized string.
I put in a breakpoint and checking CurrentUICulture gave me this:
Thread.CurrentThread.CurrentUICulture
{sv}
calendar: null
Calendar: {System.Globalization.GregorianCalendar}
CompareInfo: {CompareInfo - sv}
compareInfo: {CompareInfo - sv}
CreatedDomainID: 2
cultureID: 127
CultureTypes: NeutralCultures | InstalledWin32Cultures | FrameworkCultures
DateTimeFormat: {System.Globalization.DateTimeFormatInfo}
dateTimeInfo: {System.Globalization.DateTimeFormatInfo}
DisplayName: "Swedish"
EnglishName: "Swedish"
HasInvariantCultureName: false
IetfLanguageTag: "sv"
IsNeutralCulture: true
IsReadOnly: false
IsSafeCrossDomain: true
KeyboardLayoutId: 29
LCID: 29
m_consoleFallbackCulture: null
m_createdDomainID: 2
m_cultureData: {System.Globalization.CultureData}
m_dataItem: 0
m_isInherited: false
m_isReadOnly: false
m_isSafeCrossDomain: true
m_name: "sv"
m_nonSortName: "sv"
m_parent: {}
m_sortName: "sv"
m_useUserOverride: false
Name: "sv"
NativeName: "svenska"
NumberFormat: {System.Globalization.NumberFormatInfo}
numInfo: {System.Globalization.NumberFormatInfo}
OptionalCalendars: {System.Globalization.Calendar[1]}
Parent: {}
Region: {SE}
regionInfo: {SE}
SortName: "sv"
textInfo: null
TextInfo: {TextInfo - sv}
ThreeLetterISOLanguageName: "swe"
ThreeLetterWindowsLanguageName: "SVE"
TwoLetterISOLanguageName: "sv"
UseUserOverride: true
So I would think it should work