mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
finish setup wizard and ui language-keyboard feature
This commit is contained in:
@@ -673,4 +673,6 @@ export default {
|
||||
709: 'Laufwerk',
|
||||
710: 'Übertragen',
|
||||
711: 'Die Liste ist leer',
|
||||
712: 'Jetzt neu starten',
|
||||
713: 'Später',
|
||||
} satisfies i18n
|
||||
|
||||
@@ -673,4 +673,6 @@ export const ENGLISH = {
|
||||
'Drive': 709, // as in, a storage device
|
||||
'Transfer': 710, // the verb
|
||||
'The list is empty': 711,
|
||||
'Restart now': 712,
|
||||
'Later': 713, // as in, (do it) later
|
||||
} as const
|
||||
|
||||
@@ -673,4 +673,6 @@ export default {
|
||||
709: 'Unidad',
|
||||
710: 'Transferir',
|
||||
711: 'La lista está vacía',
|
||||
712: 'Reiniciar ahora',
|
||||
713: 'Más tarde',
|
||||
} satisfies i18n
|
||||
|
||||
@@ -673,4 +673,6 @@ export default {
|
||||
709: 'Disque',
|
||||
710: 'Transférer',
|
||||
711: 'La liste est vide',
|
||||
712: 'Redémarrer maintenant',
|
||||
713: 'Plus tard',
|
||||
} satisfies i18n
|
||||
|
||||
@@ -673,4 +673,6 @@ export default {
|
||||
709: 'Dysk',
|
||||
710: 'Przenieś',
|
||||
711: 'Lista jest pusta',
|
||||
712: 'Uruchom ponownie teraz',
|
||||
713: 'Później',
|
||||
} satisfies i18n
|
||||
|
||||
@@ -58,3 +58,5 @@ export * from './util/rpc.util'
|
||||
export * from './util/to-guid'
|
||||
export * from './util/to-local-iso-string'
|
||||
export * from './util/unused'
|
||||
export * from './util/keyboards'
|
||||
export * from './util/languages'
|
||||
|
||||
90
web/projects/shared/src/util/keyboards.ts
Normal file
90
web/projects/shared/src/util/keyboards.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { LanguageCode } from './languages'
|
||||
|
||||
/**
|
||||
* Keyboard layout codes
|
||||
*/
|
||||
export type KeyboardCode = 'us' | 'gb' | 'es' | 'latam' | 'de' | 'fr' | 'pl'
|
||||
|
||||
/**
|
||||
* Keyboard layout display names
|
||||
*/
|
||||
export type KeyboardName =
|
||||
| 'US English'
|
||||
| 'UK English'
|
||||
| 'Spanish'
|
||||
| 'Latin American'
|
||||
| 'German'
|
||||
| 'French'
|
||||
| 'Polish'
|
||||
|
||||
/**
|
||||
* Keyboard layout definition
|
||||
*/
|
||||
export interface Keyboard {
|
||||
code: KeyboardCode
|
||||
name: KeyboardName
|
||||
}
|
||||
|
||||
/**
|
||||
* Full keyboard configuration for backend API
|
||||
*/
|
||||
export interface FullKeyboard {
|
||||
layout: string
|
||||
model: string | null
|
||||
variant: string | null
|
||||
options: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyboard layouts grouped by language code
|
||||
*/
|
||||
export const KEYBOARDS_BY_LANGUAGE: Record<LanguageCode, Keyboard[]> = {
|
||||
en: [
|
||||
{ code: 'us', name: 'US English' },
|
||||
{ code: 'gb', name: 'UK English' },
|
||||
],
|
||||
es: [
|
||||
{ code: 'es', name: 'Spanish' },
|
||||
{ code: 'latam', name: 'Latin American' },
|
||||
],
|
||||
de: [{ code: 'de', name: 'German' }],
|
||||
fr: [{ code: 'fr', name: 'French' }],
|
||||
pl: [{ code: 'pl', name: 'Polish' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* All available keyboard layouts
|
||||
*/
|
||||
export const ALL_KEYBOARDS: Keyboard[] = [
|
||||
{ code: 'us', name: 'US English' },
|
||||
{ code: 'gb', name: 'UK English' },
|
||||
{ code: 'es', name: 'Spanish' },
|
||||
{ code: 'latam', name: 'Latin American' },
|
||||
{ code: 'de', name: 'German' },
|
||||
{ code: 'fr', name: 'French' },
|
||||
{ code: '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 languageKeyboardCodes = new Set(languageKeyboards.map(kb => kb.code))
|
||||
const otherKeyboards = ALL_KEYBOARDS.filter(
|
||||
kb => !languageKeyboardCodes.has(kb.code),
|
||||
).sort((a, b) => a.name.localeCompare(b.name))
|
||||
return [...languageKeyboards, ...otherKeyboards]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for a keyboard code.
|
||||
*/
|
||||
export function getKeyboardName(
|
||||
code: KeyboardCode | string,
|
||||
): KeyboardName | string {
|
||||
const keyboard = ALL_KEYBOARDS.find(kb => kb.code === code)
|
||||
if (keyboard) return keyboard.name
|
||||
return code // fallback to the code 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: 'english', nativeName: 'English' },
|
||||
{ code: 'es', name: 'spanish', nativeName: 'Español' },
|
||||
{ code: 'de', name: 'german', nativeName: 'Deutsch' },
|
||||
{ code: 'fr', name: 'french', nativeName: 'Français' },
|
||||
{ code: 'pl', name: 'polish', nativeName: 'Polski' },
|
||||
]
|
||||
|
||||
/**
|
||||
* Maps i18n language names to ISO language codes
|
||||
*/
|
||||
export const LANGUAGE_TO_CODE: Record<Languages, LanguageCode> = {
|
||||
english: 'en',
|
||||
spanish: 'es',
|
||||
german: 'de',
|
||||
french: 'fr',
|
||||
polish: 'pl',
|
||||
}
|
||||
|
||||
/**
|
||||
* Params for setting language via API
|
||||
*/
|
||||
export interface SetLanguageParams {
|
||||
language: Languages
|
||||
}
|
||||
Reference in New Issue
Block a user