Can't change default language of an assembly i

2019-07-30 00:21发布

My application supports three languages: en, es, and fr. When I build my (clean, from a template) UWP application, I get the message:

warning PRI257: 0xdef00522 - Resources found for language(s) 'en,es,fr' but no resources found for default language(s): 'en-US'. Change the default language or qualify resources with the default language.

So then I go into the manifest and change the default language from en-US to en-GB and when I recompile I get:

warning PRI257: 0xdef00522 - Resources found for language(s) 'en,es,fr' but no resources found for default language(s): 'en-GB,en-US'. Change the default language or qualify resources with the default language.

What gives? How do I replace the default language in a UWP application so that it doesn't try to find en-US resources?

1条回答
爷、活的狠高调
2楼-- · 2019-07-30 01:11

To remove the warning, you have to update the language in 2 places:

  • Default language in appxmanifest, which gets saved in the csproj file as <DefaultLanguage>en-GB</DefaultLanguage>

  • Neutral assembly language, which is saved in the AssemblyInfo file as [assembly: NeutralResourcesLanguage("en-GB")] and can also be changed through the project's properties > assembly information.

Assemly information

Next to that, you have to use a full language qualifier (en-US, en-GB, ...) as the default language, as 'en' gets just redirected to en-US as the default language. Other languages can be language-only qualifiers (fr).

Note that specifying your assets with a full qualifier doesn't break other regional languages from using these resources.

Windows does cross regional matching. For example, en-US matches en-US, then en, and then en-*.

Imho it's even better to use the full qualifier as your translation is done in one of the regional languages (quite often the main region), so fr-FR is more accurate to tag your resource file than just fr.

查看更多
登录 后发表回答