Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
@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:
C#
@Html.Raw(string.Format("{0}", Html.ActionLink(@Resources.MyProject.UI_NewFAQuestion, "Create", new { returnUrl = Request.Url.AbsoluteUri })))



C#
@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:
C#
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900