Muhammad Touseef
Muhammad Touseef

Reputation: 4455

uwp localization with 1 resource file for all variants of a language

I know how localization in uwp works and I currently have en-US and es-es Resouce files.

What I want to ask is can I just use 1 resource file i.e en and will that affect all variants of English language? like en-us , en-as and all others? and then 1 file for Spanish i.e : es and so on.

all language variants have only few differences between them which are negligible almost in my app. I noticed my app has most of its users from Spain and US only. I assume that is because I am only supporting these 2 languages right now. So I want to support all variants of Spanish and all variants of English but only with 2 files, would that work or do I need to provide 1 file for each variant?

Upvotes: 0

Views: 128

Answers (2)

Imanol Zubiaurre
Imanol Zubiaurre

Reputation: 161

Try checking first if the current app language is any english variant (en-US, en-AS, ...) and if it's true then override it with the one you want.

If ( CurretLanguage == "en-US" || CurrentLanguage == "en-AS" || ...) 
{
      Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";
}

Upvotes: 1

Tany3450
Tany3450

Reputation: 338

Yes, you can do it with single file by just using short language name. In your case, it should be Resources.en.resx for english and Resources.es.resx for spanish. You can refer here for language tags.

Upvotes: 0

Related Questions