fix: use simple languagnes names

This commit is contained in:
Nybkox
2025-03-04 21:16:44 +01:00
parent 1c3032068e
commit 8d4f9fd953
5 changed files with 14 additions and 68 deletions

View File

@@ -130,8 +130,8 @@ ORDER BY
name="localization.language"
isNative
options={[
{ value: 'en-US', label: 'English' },
{ value: 'cs-CZ', label: 'Czech' },
{ value: 'en', label: 'English' },
{ value: 'cs', label: 'Czech' },
]}
on:change={() => {
setTimeout(() => {

View File

@@ -1,31 +1,34 @@
import enUS from '../../../translations/en-US.json';
import csCZ from '../../../translations/cs-CZ.json';
import cs from '../../../translations/cs.json';
import MessageFormat, { MessageFunction } from '@messageformat/core';
import { getStringSettingsValue } from './settings/settingsTools';
const translations = {
'en-US': enUS,
'cs-CZ': csCZ,
en: {},
cs,
};
const supportedLanguages = Object.keys(translations);
const compiledMessages: Partial<Record<string, Record<string, MessageFunction<'string'>>>> = {};
const defaultLanguage = 'en';
export function getSelectedLanguage(): string {
const borwserLanguage = getBrowserLanguage();
const selectedLanguage = getStringSettingsValue('localization.language', borwserLanguage);
if (!supportedLanguages.includes(selectedLanguage)) return 'en-US';
if (!supportedLanguages.includes(selectedLanguage)) return defaultLanguage;
return selectedLanguage;
}
export function getBrowserLanguage(): string {
if (typeof window !== 'undefined') {
return (navigator.languages && navigator.languages[0]) || navigator.language || 'en-US';
return (
(navigator.languages && navigator.languages[0]).slice(0, 2) || navigator.language.slice(0, 2) || defaultLanguage
);
}
return 'en-US';
return defaultLanguage;
}
type TranslateOptions = {
@@ -34,7 +37,7 @@ type TranslateOptions = {
};
function getTranslation(key: string, defaultMessage: string, language: string) {
const selectedTranslations = translations[language] ?? enUS;
const selectedTranslations = translations[language] ?? {};
const translation = selectedTranslations[key];
if (!translation) {

View File

@@ -1,58 +0,0 @@
{
"app.preparing_pluguns": "*** Preparing plugins ...",
"app.starting": "*** Starting DbGate",
"command.data_grid.revert_all_changes.name": "*** Revert all changes",
"command.data_grid.revert_all_changes.toolbar_name": "*** Revert all",
"command.data_grid.revert_row_changes": "*** Revert row changes",
"command.datagrid.add_new_column.name": "*** Add new column",
"command.datagrid.add_new_column.toolbar_name": "*** New column",
"command.datagrid.clone_rows.name": "*** Clone rows",
"command.datagrid.clone_rows.toolbar_name": "*** Clone row(s)",
"command.datagrid.copy_to_clipboard.name": "*** Copy to clipboard",
"command.datagrid.delete_selected_rows.name": "*** Delete selected rows",
"command.datagrid.delete_selected_rows.toolbar_name": "*** Delete row(s)",
"command.datagrid.edit_json_document.name": "*** Edit row as JSON document",
"command.datagrid.insert_new_row.name": "*** Insert new row",
"command.datagrid.insert_new_row.toolbar_name": "*** New row",
"command.datagrid.load_cell_from_file.name": "*** Load cell from file",
"command.datagrid.open_json_array_in_sheet.name": "*** Open array as table",
"command.datagrid.open_selection_in_map.name": "*** Open selection in map",
"command.datagrid.reconnect.name": "*** Reconnect",
"command.datagrid.redo.name": "*** Redo",
"command.datagrid.remove_field.name": "*** Remove field",
"command.datagrid.save_cell_to_file.name": "*** Save cell to file",
"command.datagrid.set_null.name": "*** Set NULL",
"command.datagrid.undo.name": "*** Undo",
"command.datagrid.view_json_document.name": "*** View row as JSON document",
"command.datagrid.view_json_value.name": "*** View cell as JSON document",
"command.tabs.addToFavorites": "*** Add current tab to favorites",
"command.tabs.closeAll": "*** Close all tabs",
"command.tabs.closeTab": "*** Close tab",
"command.tabs.closeTabsButCurrentDb": "*** Close tabs but current DB",
"command.tabs.closeTabsWithCurrentDb": "*** Close tabs with current DB",
"command.tabs.nextTab": "*** Next tab",
"command.tabs.previousTab": "*** Previous tab",
"command.tabs.reopenClosedTab": "*** Reopen closed tab",
"common.archive": "*** Archive",
"common.connections": "*** Connections",
"common.database": "*** Database",
"common.query": "*** Query",
"common.refresh": "*** Refresh",
"common.save": "*** Save",
"common.schema": "*** Schema",
"error.driver_not_found": "*** Invalid database connection, driver not found",
"schema.add": "*** Add new schema",
"schema.create_schema": "*** Create schema",
"schema.delete": "*** Delete schema",
"schema.reset_to_default": "*** Reset to default",
"schema.schema_name": "*** Schema name",
"settings.localization": "Localizace",
"source.source_files": "*** Source files",
"source.tables_views_collections": "*** Tables / views / collections",
"tab.administration": "*** Administration",
"widget.database_content": "*** Database content",
"widget.databases": "*** Databases",
"widget.keys": "*** Keys",
"widget.pinned": "*** Pinned",
"widget.tables_views_functions": "*** Tables, views, functions"
}

1
translations/cs.json Normal file
View File

@@ -0,0 +1 @@
{}