clean up translations

This commit is contained in:
Aria Moradi
2023-02-14 16:28:37 +03:30
parent 6f3bc1bc4e
commit 76d44bd657
6 changed files with 25 additions and 18 deletions

View File

@@ -19,7 +19,8 @@ const i18n = use(initReactI18next)
interpolation: { interpolation: {
escapeValue: false, escapeValue: false,
}, },
debug: true, returnNull: false,
debug: process.env.NODE_ENV !== 'production',
}); });
export default i18n; export default i18n;

11
src/i18n/locale/en.json Normal file
View File

@@ -0,0 +1,11 @@
{
"screens": {
"Library": {
"Library": "Library",
"could-not-load-categories": "Could not load categories",
"your-library-is-empty": "Your Library is empty",
"category-is-empty": "Category is Empty",
"could-not-load-manga": "Could not load manga"
}
}
}

View File

@@ -1,4 +0,0 @@
{
"DefaultNavBar.navbarItems.Library": "Library",
"screens/Library/Library": "Library"
}

View File

@@ -1,4 +0,0 @@
{
"DefaultNavBar.navbarItems.Library": "fr(Library)",
"screens/Library/Library": "fr(Library)"
}

View File

@@ -5,8 +5,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import en from 'i18n/resources/en.json'; import en from 'i18n/locale/en.json';
import fr from 'i18n/resources/fr.json';
const translationHelper = (lng: any) => ({ const translationHelper = (lng: any) => ({
translation: lng, translation: lng,
@@ -14,7 +13,6 @@ const translationHelper = (lng: any) => ({
const resources = { const resources = {
en: translationHelper(en), en: translationHelper(en),
fr: translationHelper(fr),
}; };
export default resources; export default resources;

View File

@@ -39,7 +39,7 @@ export default function Library() {
const { setTitle, setAction } = useContext(NavbarContext); const { setTitle, setAction } = useContext(NavbarContext);
useEffect(() => { useEffect(() => {
setTitle(t('screens/Library/Library')); setTitle(t('screens.Library.Library'));
setAction( setAction(
<> <>
<AppbarSearch /> <AppbarSearch />
@@ -58,7 +58,12 @@ export default function Library() {
}; };
if (tabsError != null) { if (tabsError != null) {
return <EmptyView message="Could not load categories" messageExtra={tabsError?.message ?? tabsError} />; return (
<EmptyView
message={t('screens.Library.could-not-load-categories')}
messageExtra={tabsError?.message ?? tabsError}
/>
);
} }
if (loading) { if (loading) {
@@ -66,7 +71,7 @@ export default function Library() {
} }
if (tabs.length === 0) { if (tabs.length === 0) {
return <EmptyView message="Your Library is empty" />; return <EmptyView message={t('screens.Library.your-library-is-empty')} />;
} }
if (tabs.length === 1) { if (tabs.length === 1) {
@@ -74,7 +79,7 @@ export default function Library() {
<LibraryMangaGrid <LibraryMangaGrid
mangas={mangas} mangas={mangas}
lastLibraryUpdate={lastLibraryUpdate} lastLibraryUpdate={lastLibraryUpdate}
message="Your Library is empty" message={t('screens.Library.your-library-is-empty') as string}
isLoading={activeTab != null && mangaLoading} isLoading={activeTab != null && mangaLoading}
/> />
); );
@@ -105,14 +110,14 @@ export default function Library() {
{tab === activeTab && {tab === activeTab &&
(mangaError ? ( (mangaError ? (
<EmptyView <EmptyView
message="Could not load manga" message={t('screens.Library.could-not-load-manga')}
messageExtra={mangaError?.message ?? mangaError} messageExtra={mangaError?.message ?? mangaError}
/> />
) : ( ) : (
<LibraryMangaGrid <LibraryMangaGrid
mangas={mangas} mangas={mangas}
lastLibraryUpdate={lastLibraryUpdate} lastLibraryUpdate={lastLibraryUpdate}
message="Category is Empty" message={t('screens.Library.category-is-empty') as string}
isLoading={mangaLoading} isLoading={mangaLoading}
/> />
))} ))}