From 7af01713180066b6dc1061dae930840e48c60fec Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 30 Mar 2022 01:36:22 +0200 Subject: feat(main): Add localization support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add i18next with a custom backend to the main process to load localization from file. Missing localizations are written to a missing localizations file in debug mode, but silently fall back in production mode. We will also need to add a custom backend for the renderer process that communicates with the main process. (i18next-fs-electron-backend is not applicable here, because we need localizations both in the main and renderer processes.) Signed-off-by: Kristóf Marussy --- packages/main/src/i18n/LocalizationRepository.ts | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packages/main/src/i18n/LocalizationRepository.ts (limited to 'packages/main/src/i18n/LocalizationRepository.ts') diff --git a/packages/main/src/i18n/LocalizationRepository.ts b/packages/main/src/i18n/LocalizationRepository.ts new file mode 100644 index 0000000..041449d --- /dev/null +++ b/packages/main/src/i18n/LocalizationRepository.ts @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import type { ResourceKey } from 'i18next'; + +export default interface LocatlizationRepository { + getResourceContents( + language: string, + namespace: string, + ): Promise; + + getMissingResourceContents( + language: string, + namespace: string, + ): Promise; + + setMissingResourceContents( + language: string, + namespace: string, + data: ResourceKey, + ): Promise; +} -- cgit v1.2.3-54-g00ecf