Some culture (ht and sm) resource dlls missing with Dotnet 6 localization

Carrie Owen 1 Reputation point
2022-11-14T18:17:01.033+00:00

I added localization support to a dotnet 6 web api and a dotnet6 wpf application by adding a shared resource class and resource files for that class. For the cultures da, de, en, es, fi, fr, it, ja, ko, nl, pt, ru, sv, and uk, everything works great. When adding cultures ht and sm, the resource files are not included under the class and after compiling there is no directory with a resource dll for ht and sm. 260215-screenshot-2022-11-14-111111.jpg

The following code does work to have ht and sm show up in the possible languages list, but once selecting them everything is still at the default culture:
var _SupportedCultures = new List<CultureInfo> {
new CultureInfo("da"),
new CultureInfo("de"),
new CultureInfo("en"),
new CultureInfo("es"),
new CultureInfo("fi"),
new CultureInfo("fr"),
new CultureInfo("ht"),
new CultureInfo("it"),
new CultureInfo("ja"),
new CultureInfo("ko"),
new CultureInfo("nl"),
new CultureInfo("pt"),
new CultureInfo("ru"),
new CultureInfo("sm"),
new CultureInfo("sv"),
new CultureInfo("to"),
new CultureInfo("uk"),
new CultureInfo("zh-Hant")
};

builder.Services.Configure<RequestLocalizationOptions>(options => {
options.DefaultRequestCulture = new RequestCulture("en");
options.SupportedCultures = _SupportedCultures;
options.SupportedUICultures = _SupportedCultures;
});
...
builder.Services.AddLocalization();
...
builder.Services.AddControllers().AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);
...
app.UseRequestLocalization();

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,359 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,076 Reputation points Microsoft Vendor
    2022-11-15T06:09:54.18+00:00

    Hi @Carrie Owen ,

    First, please check the Translation.ht.resx and Translation.sm.resx file's build action property, it should be Embedded resource.

    Second, you can check the CultureInfo Class, the ht and sm are not a valid/supported language tag in the windows systems. For detailed culture information for Windows systems, see the Language tag column in the list of language/region names supported by Windows. So, it doesn't contain the relate folder.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments