-
-
Notifications
You must be signed in to change notification settings - Fork 102
support chinese language #42
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
Changes from 1 commit
80879c0
566eef1
7e4c20e
8e57987
f422002
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| window.blazorCulture = { | ||
| get: function () { | ||
| return window.localStorage['BlazorCulture']; | ||
| }, | ||
| set: function (value) { | ||
| window.localStorage['BlazorCulture'] = value; | ||
| } | ||
| }; | ||
|
|
||
| window.setCultureCookie = function (culture) { | ||
| var cookieValue = 'c=' + culture + '|uic=' + culture; | ||
| var secure = (location.protocol === 'https:') ? '; secure' : ''; | ||
| document.cookie = '.AspNetCore.Culture=' + cookieValue + '; path=/; samesite=lax' + secure; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,29 @@ | ||
| @* | ||
| @* | ||
| // Copyright (c) Alex Reich. | ||
| // Licensed under the CC BY 4.0 License. | ||
| *@ | ||
| @using RulesEngineEditor.Resources | ||
| <div> | ||
| <ul class="nav flex-column"> | ||
| <li class="nav-item px-3"> | ||
| <NavLink class="nav-link" href="" Match="NavLinkMatch.All"> | ||
| <span class="oi oi-home" aria-hidden="true"></span> Home | ||
| <span class="oi oi-home" aria-hidden="true"></span> @RulesEngineEditor.Resources.SharedResources.Home | ||
| </NavLink> | ||
| </li> | ||
| <li class="nav-item px-3"> | ||
| <NavLink class="nav-link" href="demo"> | ||
| <span class="oi oi-book" aria-hidden="true"></span> Demo | ||
| <span class="oi oi-book" aria-hidden="true"></span> @RulesEngineEditor.Resources.SharedResources.Demo | ||
| </NavLink> | ||
| </li> | ||
| <li class="nav-item px-3"> | ||
| <NavLink class="nav-link" href="new"> | ||
| <span class="oi oi-aperture" aria-hidden="true"></span> New | ||
| <span class="oi oi-aperture" aria-hidden="true"></span> @RulesEngineEditor.Resources.SharedResources.New | ||
| </NavLink> | ||
| </li> | ||
| <li class="nav-item px-3"> | ||
| <NavLink class="nav-link" href="standalone"> | ||
| <span class="oi oi-fullscreen-enter" aria-hidden="true"></span> Standalone | ||
| <span class="oi oi-fullscreen-enter" aria-hidden="true"></span> @RulesEngineEditor.Resources.SharedResources.Standalone | ||
| </NavLink> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| window.blazorCulture = { | ||
| get: function () { | ||
| return window.localStorage['BlazorCulture']; | ||
| }, | ||
| set: function (value) { | ||
| window.localStorage['BlazorCulture'] = value; | ||
| } | ||
| }; | ||
|
|
||
| window.setCultureCookie = function (culture) { | ||
| var cookieValue = 'c=' + culture + '|uic=' + culture; | ||
| var secure = (location.protocol === 'https:') ? '; secure' : ''; | ||
| document.cookie = '.AspNetCore.Culture=' + cookieValue + '; path=/; samesite=lax' + secure; | ||
alexreich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||||||||
| @using Microsoft.JSInterop | ||||||||||||||||||||||||||||||||
| @inject IJSRuntime JS | ||||||||||||||||||||||||||||||||
| @inject NavigationManager Nav | ||||||||||||||||||||||||||||||||
| @code { | ||||||||||||||||||||||||||||||||
| private string selectedCulture = System.Globalization.CultureInfo.CurrentUICulture.Name; | ||||||||||||||||||||||||||||||||
| private async Task OnChange(ChangeEventArgs e) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| selectedCulture = e.Value?.ToString() ?? "en-US"; | ||||||||||||||||||||||||||||||||
| await JS.InvokeVoidAsync("blazorCulture.set", selectedCulture); | ||||||||||||||||||||||||||||||||
| await JS.InvokeVoidAsync("setCultureCookie", selectedCulture); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| await JS.InvokeVoidAsync("blazorCulture.set", selectedCulture); | |
| await JS.InvokeVoidAsync("setCultureCookie", selectedCulture); | |
| try | |
| { | |
| await JS.InvokeVoidAsync("blazorCulture.set", selectedCulture); | |
| await JS.InvokeVoidAsync("setCultureCookie", selectedCulture); | |
| } | |
| catch (JSException) | |
| { | |
| // If the culture.js script or functions are unavailable, ignore and continue. | |
| } | |
| catch (Exception) | |
| { | |
| // Swallow unexpected errors from JS interop to avoid breaking navigation. | |
| } |
Outdated
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The culture switcher select element lacks an accessible label. Screen reader users won't know what this dropdown is for. Add either a visible label, an aria-label attribute, or associate it with a label element using aria-labelledby to describe its purpose (e.g., "Select Language" or "Language Selector").
Uh oh!
There was an error while loading. Please reload this page.