Page 1 of 1

Resource.resx and CultureInfo

Posted: Thu Jan 12, 2017 10:50 pm
by xwang
Hello Team,

2 questions about Resource file.

I created a resource file 'DefaultResource.resx' in Projects Configure.
In the file, key-value and culture are setted.
for example: SupportedCultures:ja-JP.

In the simulator, we can get the value according to the key.
But in the browser, exception "No resources available for culture 'ja-JP'." occurred.

Any idea about the error above? An example of how to use resource.resx in CSHTML5 is really helpful.

In the simulator,we can not get the value ‘’.
Is 'System.Globalization.CultureInfo.CurrentUICulture' supported in CSHTML5?


Re: Resource.resx and CultureInfo

Posted: Fri Jan 13, 2017 6:17 am
by JS-Support @Userware

Support for "System.Globalization.CultureInfo.CurrentUICulture" is expected in 2017.

RESX files are currently supported but they cannot be localized.

Localizable RESX are on the roadmap for 2017 as well:

If you need the feature quickly, please contact us at for a quote and precise timescale.

Thanks a lot.

Re: Resource.resx and CultureInfo

Posted: Tue Jan 17, 2017 10:19 pm
by xwang

Thank you for your reply.
We are going to evaluate the priority of this function in our application.
Will contact the support, if we need more help quickly.

Re: Resource.resx and CultureInfo

Posted: Thu Feb 02, 2017 10:27 pm
by juanpablogc
Hello, this is my first entry in the forum, I have just deployed in Visual Studio the examples and it is really impressive to me. I am decided to create my website with this great platform.

Is there a workaround to get the culture of the thread? is it possible to do with the free edition?

Thank you, my first impression about this is awesome.

Re: Resource.resx and CultureInfo

Posted: Thu Nov 01, 2018 10:05 pm
by berend
I have applied a fairly simple workaround in my app. The silverlight app is bilingual: the resx strings are en-US with a satellite assembly Dutch nl-NL. However, as the host application supports 5 languages, the workaround should be suitable for more than two languages and handle the fallback to English.

1. Open the nl-NL satellite resx file in notepad++ or similar
2. Give all string ID's a postfix _nl, where nl is the 2-letter language code. If your app supports regional languages, use _nl_NL or language ID like _0413 instead.
For me it was replace [" xml:space="preserve">] by [_nl" xml:space="preserve">]
3. Copy the data part of the satellite strings table to the end of the main resx strings table.
Because I used a postfix, the strings will be sorted by ID, then language in the VS resource editor. This is more convenient than prefix sort if you need to correct translations or add new strings:

The system works if you read strings in code-behind. My app uses a common function, that I changed to handle the new language postfix. In the CSHTML5-version, I pass a 2-letter language ID in a query parameter and store it in the new Language field, the Silverlight version ignores the new field and leaves it as "EN":

Code: Select all

    public static string Language = "EN";
    public static string GetResource(string sResourceKey)
      string sResource = string.Empty;
        if (Language != "EN")
          sResource = Resources.Strings.ResourceManager.GetString(sResourceKey + "_" + Language.ToLower());
      catch { }
        if (string.IsNullOrEmpty(sResource))
          sResource = Resources.Strings.ResourceManager.GetString(sResourceKey);
      catch (Exception ex) { Common.SendLogToServer(ex); }
      return sResource;

The first try/catch or the check for empty string below cause a fall-back to English if the localized string does not exist, so that the behavior for missing strings is the same as in Silverlight or WPF. As the Silverlight version never sets the Language field, the same code can still exist in both versions of the app (I expect to have to maintain the Silverlight version for at least a year after release of the CSHTML5 equivalent).

To see it in action:

Re: Resource.resx and CultureInfo

Posted: Fri Nov 02, 2018 7:27 am
by JS-Support @Userware
Thank you berend for posting this workaround!