-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,47 @@ | ||
<BlazingStoryApp | ||
@implements IAsyncDisposable | ||
|
||
@inject IJSRuntime JsRuntime | ||
|
||
<BlazingStoryApp | ||
EnableHotReloading="true" | ||
Title="TeamAssistUI docs" | ||
Assemblies="[typeof(App).Assembly]" | ||
DefaultLayout="typeof(DefaultLayout)" | ||
AvailableColorSchemes="AvailableColorSchemes.Dark"/> | ||
AvailableColorSchemes="AvailableColorSchemes.Dark"> | ||
<BrandLogoArea> | ||
UI docs <a href="#" @onclick="ChangeCulture" @onclick:preventDefault="true" class="link_change-culture"> | ||
@_targetLanguage | ||
</a> | ||
</BrandLogoArea> | ||
</BlazingStoryApp> | ||
|
||
@code { | ||
private string _targetLanguage = LanguageSettings.DefaultLanguageId.Value; | ||
|
||
private IJSObjectReference? _appModule; | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
_appModule = await JsRuntime.InvokeAsync<IJSObjectReference>( | ||
"import", | ||
"./App.razor.js"); | ||
|
||
var currentCulture = await _appModule.InvokeAsync<string?>("currentCulture"); | ||
|
||
_targetLanguage = currentCulture == "en" ? "ru" : "en"; | ||
} | ||
} | ||
|
||
private async Task ChangeCulture() | ||
{ | ||
if (_appModule is not null) | ||
await _appModule.InvokeVoidAsync("changeCulture", _targetLanguage); | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (_appModule is not null) | ||
await _appModule.DisposeAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const cultureKey = "current_culture"; | ||
|
||
export function changeCulture(culture) { | ||
window.localStorage.setItem(cultureKey, culture); | ||
window.location.reload(); | ||
} | ||
|
||
export function currentCulture() { | ||
let culture = window.localStorage.getItem(cultureKey); | ||
|
||
return culture ?? "en"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters