I have an localizeable c# application.
There is a file Localization.resx
and a file Localization.de.resx
.
The Localization.resx
contains the invariant language - it is english.
The user should be able to select his preferred language. I found the first answer of this question Programmatic way to get all the available languages (in satellite assemblies) to determine which cultures are available. I see that there is de
and InvariantCulture
available.
But I can't offer InvariantCulture. An user wont know what this is. Instead I should offer en
.
I can't rename Localization.resx
to Localization.en.resx
, since this file is needed to create the Class holding the resources.
I could copy Localization.resx
to Localization.en.resx
, but then I would always have to keep those files consistent and also need to remove InvariantCulture
from the available cultures.
I could write a converter that visualizes the the InvariantCulture
as en
. But this, I think, is an ugly hack.
Any help please?
You can use the NeutralResourcesLanguageAttribute assembly attribute to set the neutral language.
[assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.Satellite)]
This also makes it "fallback" to other satellites if a key is not found in one resource (if you ask for a key which is not defined in resource.en-US.resx
, it'll search in resource.en.resx
and finally in resource.resx
)
I'm not sure how you are listing the language names, but in case this still gives InvariantCulture
, you could have an empty Localization.en.resx
, and with this method it'll find all missing resources in Localization.resx
, so no need to have them in sync.