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

@@ -19,6 +19,7 @@ import client from 'util/client';
import { langCodeToName, langSortCmp, sourceDefualtLangs, sourceForcedDefaultLangs } from 'util/language';
import useLocalStorage from 'util/useLocalStorage';
import { ISource } from 'typings';
import { useTranslation } from 'react-i18next';
function sourceToLangList(sources: ISource[]) {
const result: string[] = [];
@@ -34,6 +35,8 @@ function sourceToLangList(sources: ISource[]) {
}
const SearchAll: React.FC = () => {
const { t } = useTranslation();
const [query] = useQueryParam('query', StringParam);
const { setTitle, setAction } = useContext(NavbarContext);
const [triggerUpdate, setTriggerUpdate] = useState<number>(2);
@@ -53,7 +56,7 @@ const SearchAll: React.FC = () => {
const limit = new PQueue({ concurrency: 5 });
useEffect(() => {
setTitle('Global Search');
setTitle(t('search.title.global_search'));
setAction(<AppbarSearch />);
}, []);
@@ -146,7 +149,7 @@ const SearchAll: React.FC = () => {
}, []);
useEffect(() => {
setTitle('Sources');
setTitle(t('source.title'));
setAction(
<>
<AppbarSearch autoOpen />
@@ -210,7 +213,7 @@ const SearchAll: React.FC = () => {
setLastPageNum={setLastPageNum}
horizontal
noFaces
message={fetched[id] ? 'No manga was found!' : undefined}
message={fetched[id] ? t('manga.error.label.no_mangas_found') : undefined}
inLibraryIndicator
/>
</>