Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization did not work after publish the project. #21

Open
mikeyoshino opened this issue Oct 21, 2022 · 3 comments
Open

Localization did not work after publish the project. #21

mikeyoshino opened this issue Oct 21, 2022 · 3 comments

Comments

@mikeyoshino
Copy link

Hi,
my Blazor Wasm has 2 resource files representing 2 languages Thai, and English.
I have SetDefaultCulture method to set the default language to Thai when the application first starts.

public async static Task SetDefaultCulture(this WebAssemblyHost host)
    {
      ILocalStorageService localStorage =  host.Services.GetRequiredService<ILocalStorageService>();
      string getCulture =  await localStorage.GetItemAsStringAsync("Culture");
      CultureInfo culture;
      if (getCulture != null)
      {
        culture = new CultureInfo(getCulture);
      }
      else
      {
        await localStorage.SetItemAsStringAsync("Culture", "th-TH");
        culture = new CultureInfo("th-TH");
      }
      CultureInfo.DefaultThreadCurrentCulture = culture;
      CultureInfo.DefaultThreadCurrentUICulture = culture;
    }

but when I publish the project, the language in static files are in English.
How can I set pretender to render Thai language and setting default culture doesn't really work?

@jsakamoto
Copy link
Owner

@mikeyoshino Thank you for your report!
Honestly, I've never considered localization scenarios seriously. I'll investigate this localization scenario, and I'll try to resolve it. However, I haven't had enough time to do that recently, so it will take much longer than you expected. I'll appreciate your patience.

@jsakamoto
Copy link
Owner

@mikeyoshino
I updated the new version of the "BlazorWasmPreRendering.Build" NuGet package. This latest version allows us to set the custom locale for pre-rendering via an MSBuild property. Please see the "Locale" section of the README document.

I also attach the sample project as the following zip file.

📦BlazorWasmApp1.zip

The zip file above includes Git local repository, so you can see the commit history to know how to change to add support for pre-rendering with the "th-TH" culture. I hope that this solution will make sense to you.

@nakigoe
Copy link

nakigoe commented Jul 3, 2023

@jsakamoto Localization: the extension seems to see only one main language on the HOME page.
Do I have to write separate home pages for every language I use to have them indexed?
The home page is pre-rendered only in the en language, I will test if it is possible to fix with
<BlazorWasmPrerenderingLocale>ja-JP,en-US</BlazorWasmPrerenderingLocale>

my locales are more simple: en, ja, ru, tg, zh , but listing them is not working... :(
<BlazorWasmPrerenderingLocale>en,ja,ru,tg,zh</BlazorWasmPrerenderingLocale>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants