add translation keys (#246)

* Fix i18n tsc issue

"t" can return null by default.
This was already disabled in the config, but it had no effect on tsc.

* Fix translation in "DefaultNavBar"

key was missing and since this is a constant the translation wouldn't update in case the language got changed after first load.

* Enable typing for i18n translation keys

* Add translation keys
This commit is contained in:
schroda
2023-03-23 13:59:32 +01:00
committed by GitHub
parent 8c129f2e08
commit d58bd6cd92
56 changed files with 1030 additions and 416 deletions

View File

@@ -5,8 +5,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { t } from 'i18next';
import { useReducerLocalStorage } from 'util/useLocalStorage';
import { ChapterListOptions, ChapterOptionsReducerAction, ChapterSortMode, IChapter, NullAndUndefined } from 'typings';
import {
ChapterListOptions,
ChapterOptionsReducerAction,
ChapterSortMode,
IChapter,
NullAndUndefined,
TranslationKey,
} from 'typings';
const defaultChapterOptions: ChapterListOptions = {
active: false,
@@ -35,7 +43,7 @@ function chapterOptionsReducer(state: ChapterListOptions, actions: ChapterOption
case 'showChapterNumber':
return { ...state, showChapterNumber: !state.showChapterNumber };
default:
throw Error('This is not a valid Action');
throw Error(t('global.error.label.invalid_action'));
}
}
@@ -95,9 +103,9 @@ export const useChapterOptions = (mangaId: string) =>
defaultChapterOptions,
);
export const SORT_OPTIONS: [ChapterSortMode, string][] = [
['source', 'By Source'],
['fetchedAt', 'By Fetch date'],
export const SORT_OPTIONS: [ChapterSortMode, TranslationKey][] = [
['source', 'global.sort.label.by_source'],
['fetchedAt', 'global.sort.label.by_fetch_date'],
];
export const isFilterActive = (options: ChapterListOptions) => {