TwoSky.WebComponents.LanguageBanner
1.0.1
dotnet add package TwoSky.WebComponents.LanguageBanner --version 1.0.1
NuGet\Install-Package TwoSky.WebComponents.LanguageBanner -Version 1.0.1
<PackageReference Include="TwoSky.WebComponents.LanguageBanner" Version="1.0.1" />
<PackageVersion Include="TwoSky.WebComponents.LanguageBanner" Version="1.0.1" />
<PackageReference Include="TwoSky.WebComponents.LanguageBanner" />
paket add TwoSky.WebComponents.LanguageBanner --version 1.0.1
#r "nuget: TwoSky.WebComponents.LanguageBanner, 1.0.1"
#:package TwoSky.WebComponents.LanguageBanner@1.0.1
#addin nuget:?package=TwoSky.WebComponents.LanguageBanner&version=1.0.1
#tool nuget:?package=TwoSky.WebComponents.LanguageBanner&version=1.0.1
LanguageBanner
A language selection banner web component that detects when the user's preferred language differs from the current page language. It offers to persist the current language as the user's preference or dismiss the banner for the session.
This plugin is only compatible with the Web3 Vidyano client.
Installation
After installing the NuGet package, add the following import to your app.ts:
import "../language-banner/language-banner";
Then add the component to your app's HTML template (e.g., in the navigation bar):
<ts-language-banner display-mode="dropdown"></ts-language-banner>
Rebuild the frontend code after making these changes.
Display Modes
The component supports two display modes via the display-mode attribute:
Dropdown (default)
Shows a globe icon with the current language code. Clicking opens a dropdown menu with available languages.
<ts-language-banner display-mode="dropdown"></ts-language-banner>
Buttons
Shows all available languages as side-by-side buttons, with the active language highlighted.
<ts-language-banner display-mode="buttons"></ts-language-banner>
Language Mismatch Banner
When the user's preferred language (stored in a PreferredLanguage cookie, set by CronosCore) differs from the current page language, a banner appears with two options:
- "Use {language} everywhere" - Calls the
CronosWeb.UpdateApplicationLanguageendpoint to persist the current language as the user'sPerson.ApplicationLanguage - "Dismiss for now" - Hides the banner until the next page load
Events
The component fires the following custom events:
| Event | Detail | Description |
|---|---|---|
language-persist |
{ language: string } |
User clicked "Use everywhere" |
language-dismiss |
{ from: string, to: string } |
User clicked "Dismiss" |
language-select |
{ language: string } |
User selected a language from dropdown/buttons |
Translatable Messages
The plugin registers the following client-side messages (en, nl, fr):
LanguageBanner_Message- The mismatch banner messageLanguageBanner_UseEverywhere- The persist button labelLanguageBanner_Dismiss- The dismiss button labelLanguageBanner_LanguageName_en- Language name for EnglishLanguageBanner_LanguageName_nl- Language name for DutchLanguageBanner_LanguageName_fr- Language name for French
Styling
The component uses Shadow DOM. You can customize its appearance via CSS custom properties and ::part() selectors.
CSS Custom Properties
Override these on the host element or any ancestor:
| Variable | Default | Description |
|---|---|---|
--language-banner-bg |
#f8f9fa |
Banner background color |
--language-banner-color |
#212529 |
Banner text color |
--language-banner-padding |
12px 20px |
Banner padding |
--language-banner-shadow |
0 2px 5px rgba(0,0,0,0.1) |
Banner box shadow |
--language-banner-z-index |
1050 |
Banner z-index |
--language-banner-font-size |
14px |
Banner font size |
--language-banner-btn-padding |
8px 15px |
Button padding |
--language-banner-btn-radius |
4px |
Button border radius |
--language-banner-primary-bg |
#007bff |
"Use everywhere" button background |
--language-banner-primary-color |
white |
"Use everywhere" button text color |
--language-banner-primary-hover-bg |
#0056b3 |
"Use everywhere" button hover background |
--language-banner-secondary-bg |
#6c757d |
"Dismiss" button background |
--language-banner-secondary-color |
white |
"Dismiss" button text color |
--language-banner-secondary-hover-bg |
#545b62 |
"Dismiss" button hover background |
Example:
ts-language-banner {
--language-banner-primary-bg: var(--theme-color);
--language-banner-primary-hover-bg: var(--theme-color-lighter);
--language-banner-bg: var(--theme-color-faint);
}
CSS ::part() Selectors
For full styling control, target individual elements:
| Part name | Element |
|---|---|
banner |
The mismatch notification banner |
banner-content |
Banner message container |
banner-icon |
Globe icon in the banner |
banner-message |
Banner text |
banner-actions |
Banner button container |
btn-primary |
"Use everywhere" button |
btn-secondary |
"Dismiss" button |
dropdown |
Dropdown mode container |
trigger |
Dropdown trigger button |
menu |
Dropdown menu |
menu-item |
Dropdown menu item |
buttons |
Buttons mode container |
button |
Individual language button |
button-active |
Active language button |
Example:
ts-language-banner::part(banner) {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
ts-language-banner::part(btn-primary) {
background-color: white;
color: #764ba2;
}
Dependencies
- CronosCore (CronosCore#742) - Provides:
PreferredLanguagecookie set on login fromPerson.ApplicationLanguage(opt-in viaPreferredLanguageCookie.Enabled)CronosWeb.UpdateApplicationLanguage()— endpoint that forwards to CronosCentral viaClientInvokerand refreshes the cookie on success
Consuming App Setup
Enable the preferred language cookie in your authenticator service constructor:
public MyAuthenticatorService()
: base(..., preferredLanguageCookie: PreferredLanguageCookie.Enabled)
{ }
No additional wiring is needed — CronosWeb.UpdateApplicationLanguage() handles the CronosCentral API call and cookie refresh automatically. Requires services.AddCronosCore() to be registered.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Vidyano (>= 6.0.20260305.6307)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.