Don't miss out Virtual Happy Hour this Friday (April 26).
Don't miss out Virtual Happy Hour this Friday (April 26).
Sep 22, 2016
Nov 14, 2016
CMS Core
Closed, Fixed and tested
Steps to reproduce
1. Use a language file with this content:
<?xml version="1.0" encoding="utf-8"?> <languages> <language name="français" id="fr"> <test> <string1>French string 1</string1> </test> </language> <language name="English" id="en"> <test> <string1>English string 1</string1> <string2>English string 2</string2> </test> </language> </languages>
2. Set the localization element in Framework.config to have missing messages
<localization fallbackBehavior="MissingMessage, Echo" fallbackCulture="en">
3. Add the following code to a razor view (Example: /Views/Shared/Header.cshtml in alloy mvc templates)
@{ var resourceItems = EPiServer.Framework.Localization.LocalizationService.Current.GetAllStringsByCulture("test", System.Globalization.CultureInfo.GetCultureInfo("fr")); foreach (var item in resourceItems) { @String.Format("GetAllStringsByCulture Results -> Key: {0} Value: {1}", item.Key, item.Value) <br /> var getStringByCulture = EPiServer.Framework.Localization.LocalizationService.Current.GetStringByCulture(item.Key, System.Globalization.CultureInfo.GetCultureInfo("fr")); @String.Format("GetStringByCulture Results -> Key: {0} Value: {1}", item.Key, getStringByCulture); <br /> } }
Expected:
The output from GetAllStringByCulture produces the same result as GetStringByCulture.
Actual:
There's a difference on the string that has a translation in English but not French:
GetAllStringsByCulture Results -> Key: /test/string2 Value: [Missing text '/test/string2' for 'English']
GetStringByCulture Results -> Key: /test/string2 Value: [Missing text '/test/string2' for 'French']