0

I'm having trouble accessing localizations, the value always appears in the default language.

I have two resource files in App_GlobalResources:

  • Resource.resx contains a string with the name "Hello" and the value of "World".

  • Resource.fr.resx contains a string with the name "Hello" and the value of "Monde"

In my Razor template:

<lang:string key="Resource, Resources.Resource.Hello" xmlns:lang="http://www.composite.net/ns/localization/1.0" />

"World" is always displayed, never "Monde", even when viewing the page in French.


In a vanilla asp.net website template, with the same resources, the following code within a Razor template displays "Monde"

String cultureInfo = "fr-CA";
System.Threading.Thread.CurrentThread.CurrentCulture = 
System.Globalization.CultureInfo.CreateSpecificCulture(cultureInfo);
System.Threading.Thread.CurrentThread.CurrentUICulture = new 
System.Globalization.CultureInfo(cultureInfo);
Response.Write(ObjectInfo.Print(Resources.Resource.Hello));

However, within C1 it results in "World".


How should I be going about this?

Thanks!

1 Answers1

0

The <lang:string construct is mainly meant for XSLT templates and functions where you can't as easily fallback to calling c# code directly as in Razor.

Have you tried printing out the resource on your Razor template like this instead @Resources.Resource.Hello ?

Pauli Østerø
  • 6,878
  • 2
  • 31
  • 48
  • Yes, same result my strings are printed in the "neutral" language. – hardingxyz May 18 '17 at 12:48
  • So, when you say your page is in French, how precisely is this defined? Have you added mulitple languages under System > Languages? – Pauli Østerø May 18 '17 at 13:53
  • Yes. When the page is rendered and you view /fr/ content coming from C1 is properly localized, however, content from the resource file is not. – hardingxyz May 18 '17 at 18:00