I have a localized Blazor server-side app that supports English (US), German and Swedish. I added the required resource files for de
and sv
. So I ended up with the following files
App.resx -> invariant (fallback) culture (en-US)
App.de.resx
App.sv.resx
I didn't use de-DE
or sv-SE
so I have a fallback to the parent if, for example de-AT
or sv-FI
are configured in the user's browser.
Everything works fine when translating text.
However, I have a couple of components where I format currencies, and I do:
@string.Format(CultureInfo.CurrentCulture, "{0:C}", myValue);
However, when the page is viewed in the parent culture (de
or sv
) the value is not being formatted and the currency symbol is not being displayed.
Is there a way to get the formatting to work when using the parent culture directly? Or do I really need to specify a complete culture, ie. de-DE
and sv-SE
?
CodePudding user response:
Maybe in some lower versions of .net core, currency symbols can be displayed normally using the parent culture. But the best way is to specify the complete culture.
The design is that a "currency" is a property of a country or region, not a language. Thus, if there is no country/region in the locale name or locale tag, the design is to give back an empty string in many cases.