Skip to content

Commit

Permalink
fix(web): add missing file
Browse files Browse the repository at this point in the history
Forgotten at 37a7e80
  • Loading branch information
dgdavid committed Jul 3, 2024
1 parent 227c42f commit 179b65e
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions web/src/routes/l10n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (c) [2024] SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact SUSE LLC.
*
* To contact SUSE LLC about this file by physical or electronic mail, you may
* find current contact information at www.suse.com.
*/

import React from "react";
import { Page } from "~/components/core";
import { L10nPage, LocaleSelection, KeymapSelection, TimezoneSelection } from "~/components/l10n";
import { queryClient } from "~/context/app";
import {
configQuery,
localesQuery,
keymapsQuery,
timezonesQuery,
useL10nConfigChanges
} from "~/queries/l10n";
import { N_ } from "~/i18n";

const L10N_PATH = "/l10n";
const LOCALE_SELECTION_PATH = "locale/select";
const KEYMAP_SELECTION_PATH = "keymap/select";
const TIMEZONE_SELECTION_PATH = "timezone/select";

const l10nLoader = async () => {
const config = await queryClient.fetchQuery(configQuery());
const locales = await queryClient.fetchQuery(localesQuery());
const keymaps = await queryClient.fetchQuery(keymapsQuery());
const timezones = await queryClient.fetchQuery(timezonesQuery());

const { locales: [localeId], keymap: keymapId, timezone: timezoneId } = config;
const locale = locales.find((l) => l.id === localeId);
const keymap = keymaps.find((k) => k.id === keymapId);
const timezone = timezones.find((t) => t.id === timezoneId);

return { locale, keymap, timezone };
};

const routes = {
path: L10N_PATH,
element: <Page />,
loader: l10nLoader,
handle: {
name: N_("Localization"),
icon: "globe"
},
children: [
{
index: true,
element: <L10nPage />
},
{
path: LOCALE_SELECTION_PATH,
element: <LocaleSelection />,
},
{
path: KEYMAP_SELECTION_PATH,
element: <KeymapSelection />,
},
{
path: TIMEZONE_SELECTION_PATH,
element: <TimezoneSelection />,
}
]
};

export default routes;
export {
L10N_PATH,
LOCALE_SELECTION_PATH,
KEYMAP_SELECTION_PATH,
TIMEZONE_SELECTION_PATH
};

0 comments on commit 179b65e

Please sign in to comment.