mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
Feature/consolidate setup (#3092)
* start consolidating * add start-cli flash-os * combine install and setup and refactor all * use http * undo mock * fix translation * translations * use dialogservice wrapper * better ST messaging on setup * only warn on update if breakages (#3097) * finish setup wizard and ui language-keyboard feature * fix typo * wip: localization * remove start-tunnel readme * switch to posix strings for language internal * revert mock * translate backend strings * fix missing about text * help text for args * feat: add "Add new gateway" option (#3098) * feat: add "Add new gateway" option * Update web/projects/ui/src/app/routes/portal/components/form/controls/select.component.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * add translation --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Matt Hill <mattnine@protonmail.com> * fix dns selection * keyboard keymap also * ability to shutdown after install * revert mock * working setup flow + manifest localization * (mostly) redundant localization on frontend * version bump * omit live medium from disk list and better space management * ignore missing package archive on 035 migration * fix device migration * add i18n helper to sdk * fix install over 0.3.5.1 * fix grub config --------- Co-authored-by: Matt Hill <mattnine@protonmail.com> Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> Co-authored-by: Alex Inkin <alexander@inkin.ru> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
97
web/projects/shared/src/util/keyboards.ts
Normal file
97
web/projects/shared/src/util/keyboards.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { LanguageCode } from './languages'
|
||||
|
||||
/**
|
||||
* Keyboard layout codes (X11/Wayland)
|
||||
*/
|
||||
export type KeyboardLayout = 'us' | 'gb' | 'es' | 'latam' | 'de' | 'fr' | 'pl'
|
||||
|
||||
/**
|
||||
* Keyboard keymap codes (console/TTY)
|
||||
*/
|
||||
export type KeyboardKeymap = 'us' | 'uk' | 'es' | 'la' | 'de' | 'fr' | 'pl'
|
||||
|
||||
/**
|
||||
* Keyboard layout display names
|
||||
*/
|
||||
export type KeyboardName =
|
||||
| 'US English'
|
||||
| 'UK English'
|
||||
| 'Spanish'
|
||||
| 'Latin American'
|
||||
| 'German'
|
||||
| 'French'
|
||||
| 'Polish'
|
||||
|
||||
/**
|
||||
* Keyboard definition with layout and keymap
|
||||
*/
|
||||
export interface Keyboard {
|
||||
layout: KeyboardLayout
|
||||
keymap: KeyboardKeymap
|
||||
name: KeyboardName
|
||||
}
|
||||
|
||||
/**
|
||||
* Full keyboard configuration for backend API
|
||||
*/
|
||||
export interface FullKeyboard {
|
||||
layout: KeyboardLayout
|
||||
keymap: KeyboardKeymap
|
||||
model: string | null
|
||||
variant: string | null
|
||||
options: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyboard layouts grouped by language code
|
||||
*/
|
||||
export const KEYBOARDS_BY_LANGUAGE: Record<LanguageCode, Keyboard[]> = {
|
||||
en: [
|
||||
{ layout: 'us', keymap: 'us', name: 'US English' },
|
||||
{ layout: 'gb', keymap: 'uk', name: 'UK English' },
|
||||
],
|
||||
es: [
|
||||
{ layout: 'es', keymap: 'es', name: 'Spanish' },
|
||||
{ layout: 'latam', keymap: 'la', name: 'Latin American' },
|
||||
],
|
||||
de: [{ layout: 'de', keymap: 'de', name: 'German' }],
|
||||
fr: [{ layout: 'fr', keymap: 'fr', name: 'French' }],
|
||||
pl: [{ layout: 'pl', keymap: 'pl', name: 'Polish' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* All available keyboard layouts
|
||||
*/
|
||||
export const ALL_KEYBOARDS: Keyboard[] = [
|
||||
{ layout: 'us', keymap: 'us', name: 'US English' },
|
||||
{ layout: 'gb', keymap: 'uk', name: 'UK English' },
|
||||
{ layout: 'es', keymap: 'es', name: 'Spanish' },
|
||||
{ layout: 'latam', keymap: 'la', name: 'Latin American' },
|
||||
{ layout: 'de', keymap: 'de', name: 'German' },
|
||||
{ layout: 'fr', keymap: 'fr', name: 'French' },
|
||||
{ layout: 'pl', keymap: 'pl', name: 'Polish' },
|
||||
]
|
||||
|
||||
/**
|
||||
* Get all keyboards sorted with language-specific keyboards first,
|
||||
* then remaining keyboards alphabetically by name.
|
||||
*/
|
||||
export function getAllKeyboardsSorted(languageCode: LanguageCode): Keyboard[] {
|
||||
const languageKeyboards = KEYBOARDS_BY_LANGUAGE[languageCode]
|
||||
const languageLayouts = new Set(languageKeyboards.map(kb => kb.layout))
|
||||
const otherKeyboards = ALL_KEYBOARDS.filter(
|
||||
kb => !languageLayouts.has(kb.layout),
|
||||
).sort((a, b) => a.name.localeCompare(b.name))
|
||||
return [...languageKeyboards, ...otherKeyboards]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for a keyboard layout.
|
||||
*/
|
||||
export function getKeyboardName(
|
||||
layout: KeyboardLayout | string,
|
||||
): KeyboardName | string {
|
||||
const keyboard = ALL_KEYBOARDS.find(kb => kb.layout === layout)
|
||||
if (keyboard) return keyboard.name
|
||||
return layout // fallback to the layout itself if not found
|
||||
}
|
||||
44
web/projects/shared/src/util/languages.ts
Normal file
44
web/projects/shared/src/util/languages.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Languages } from '../i18n/i18n.service'
|
||||
|
||||
/**
|
||||
* ISO language codes
|
||||
*/
|
||||
export type LanguageCode = 'en' | 'es' | 'de' | 'fr' | 'pl'
|
||||
|
||||
/**
|
||||
* Language definition with metadata
|
||||
*/
|
||||
export interface Language {
|
||||
code: LanguageCode
|
||||
name: Languages
|
||||
nativeName: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Available languages with their metadata
|
||||
*/
|
||||
export const LANGUAGES: Language[] = [
|
||||
{ code: 'en', name: 'en_US', nativeName: 'English' },
|
||||
{ code: 'es', name: 'es_ES', nativeName: 'Español' },
|
||||
{ code: 'de', name: 'de_DE', nativeName: 'Deutsch' },
|
||||
{ code: 'fr', name: 'fr_FR', nativeName: 'Français' },
|
||||
{ code: 'pl', name: 'pl_PL', nativeName: 'Polski' },
|
||||
]
|
||||
|
||||
/**
|
||||
* Maps POSIX locale strings to ISO language codes
|
||||
*/
|
||||
export const LANGUAGE_TO_CODE: Record<Languages, LanguageCode> = {
|
||||
en_US: 'en',
|
||||
es_ES: 'es',
|
||||
de_DE: 'de',
|
||||
fr_FR: 'fr',
|
||||
pl_PL: 'pl',
|
||||
}
|
||||
|
||||
/**
|
||||
* Params for setting language via API
|
||||
*/
|
||||
export interface SetLanguageParams {
|
||||
language: Languages
|
||||
}
|
||||
Reference in New Issue
Block a user