Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more translations #908

Merged
merged 41 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e89df06
chore: strings in browseScreen
he0119 Jan 23, 2024
4dc5348
chore: update translations in strings.json
he0119 Jan 23, 2024
9aa9152
chore: translate MoreScreen and downloader.serviceRunning
he0119 Jan 24, 2024
b076171
chore: translate all things in moreScreen
he0119 Jan 24, 2024
836da7e
feat: support passing options
he0119 Jan 24, 2024
8c7e564
chore: update more translations in settings
he0119 Jan 24, 2024
933eee0
chore: translation in LibraryScreen
he0119 Jan 24, 2024
281a6a1
chore: add missing en translations
he0119 Jan 24, 2024
f9cfdd0
chore: rearrange strings path
he0119 Jan 24, 2024
d63f212
chore: translate backupScreen
he0119 Jan 24, 2024
6f280b7
chore: translate SettingsReaderScreen
he0119 Jan 24, 2024
5589d28
chore: translate statsScreen
he0119 Jan 24, 2024
c8073e0
chore: translate HistoryScreen
he0119 Jan 24, 2024
4e7302c
chore: translate NovelScreen
he0119 Jan 24, 2024
e4ffeac
chore: translate remaining strings
he0119 Jan 24, 2024
3db6f16
chore: missing translations
he0119 Jan 24, 2024
43d079d
chore: add missing and improve Chinese translation
he0119 Jan 24, 2024
b3cef49
chore: improve naming
he0119 Jan 24, 2024
50fd816
chore: remove toast section and add more translations related to noti…
he0119 Jan 25, 2024
eb86f51
revert: status translations
he0119 Jan 25, 2024
d2706f1
chore: translate NovelStatus
he0119 Jan 25, 2024
b826dca
chore: translate error messages I have encountered
he0119 Jan 25, 2024
2437ec0
chore: add more translations used in updateNotification
he0119 Jan 25, 2024
d7ad6d8
chore: update missing translations
he0119 Jan 25, 2024
d202468
chore: translate backup modal
he0119 Jan 25, 2024
acfe613
chore: translate all taskTitle
he0119 Jan 25, 2024
d124a51
chore: improve translations
he0119 Jan 25, 2024
2f9f5d0
chore: add common.example
he0119 Jan 25, 2024
c8879c3
chore: improve emptyChapterMessage
he0119 Jan 25, 2024
f640cd3
chore: rearrange backup strings
he0119 Jan 25, 2024
8a523d9
chore: flatten keys
he0119 Jan 25, 2024
40e5ea7
chore: remove unused strings
he0119 Jan 25, 2024
ccebdfb
chore: translate more stuff
he0119 Jan 26, 2024
3314343
chore: flatten aboutScreen
he0119 Jan 26, 2024
3dcb6ef
chore: flatten generalSettingsScreen
he0119 Jan 26, 2024
2e4ddc9
chore: flatten readerSettings
he0119 Jan 26, 2024
e084e4d
chore: flatten browseSettingsScreen
he0119 Jan 26, 2024
67fa44b
chore: flatten settingsScreen
he0119 Jan 26, 2024
1ceed22
chore: updated based on review
he0119 Jan 26, 2024
935796b
chore: translate DefaultCategory
he0119 Jan 26, 2024
a16f2ff
chore: fix sources translation
he0119 Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/NovelCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { NovelItem } from '@plugins/types';
import { ThemeColors } from '@theme/types';
import { useLibrarySettings } from '@hooks/persisted';
import { getUserAgent } from '@hooks/persisted/useUserAgent';
import { getString } from '@strings/translations';

interface UnreadBadgeProps {
chaptersDownloaded: number;
Expand Down Expand Up @@ -234,7 +235,7 @@ const InLibraryBadge = ({ theme }: { theme: ThemeColors }) => (
},
]}
>
In library
{getString('novelScreen.inLibaray')}
</Text>
);

Expand Down
3 changes: 2 additions & 1 deletion src/database/queries/CategoryQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { noop } from 'lodash-es';
import { BackupCategory, Category, NovelCategory, CCategory } from '../types';
import { showToast } from '@utils/showToast';
import { txnErrorCallback } from '../utils/helpers';
import { getString } from '@strings/translations';
const db = SQLite.openDatabase('lnreader.db');

const getCategoriesQuery = `
Expand Down Expand Up @@ -69,7 +70,7 @@ const deleteCategoryQuery = 'DELETE FROM Category WHERE id = ?';

export const deleteCategoryById = (category: Category): void => {
if (category.sort <= 2) {
return showToast('You cant delete default category');
return showToast(getString('categories.cantDeleteDefault'));
}
db.transaction(tx => {
tx.executeSql(
Expand Down
15 changes: 8 additions & 7 deletions src/database/queries/ChapterQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { txnErrorCallback } from '@database/utils/helpers';
import { Plugin } from '@plugins/types';
import { Update } from '../types';
import { noop } from 'lodash-es';
import { getString } from '@strings/translations';

const db = SQLite.openDatabase('lnreader.db');

Expand Down Expand Up @@ -107,7 +108,7 @@ export const getPrevChapter = (
(_txObj, results) =>
resolve(results.rows.item(results.rows.length - 1)),
() => {
showToast("There's no previous chapter");
showToast(getString('readerScreen.noPreviousChapter'));
return false;
},
);
Expand Down Expand Up @@ -137,7 +138,7 @@ export const getNextChapter = (
[novelId, chapterId],
(_txObj, results) => resolve(results.rows.item(0)),
() => {
showToast("There's no next Chapter");
showToast(getString('readerScreen.noNextChapter'));
return false;
},
);
Expand Down Expand Up @@ -255,7 +256,7 @@ export const downloadChapter = async (
try {
const plugin = getPlugin(pluginId);
if (!plugin) {
throw new Error('Plugin not found!');
throw new Error(getString('downloadScreen.pluginNotFound'));
}
const chapterText = await plugin.parseChapter(chapterUrl);
if (chapterText && chapterText.length) {
Expand All @@ -267,7 +268,7 @@ export const downloadChapter = async (
);
});
} else {
throw new Error("Either chapter is empty or the app couldn't scrape it");
throw new Error(getString('downloadScreen.chapterEmptyOrScrapeError'));
}
} catch (error) {
throw error;
Expand All @@ -291,7 +292,7 @@ const deleteDownloadedFiles = async (
}
await RNFS.unlink(path);
} catch (error) {
throw new Error('Cant delete chapter chapter folder');
throw new Error(getString('novelScreen.deleteChapterError'));
}
};

Expand Down Expand Up @@ -348,7 +349,7 @@ export const deleteDownloads = async (chapters: DownloadedChapter[]) => {
);
db.transaction(tx => {
tx.executeSql('UPDATE Chapter SET isDownloaded = 0', [], () =>
showToast('Deleted all Downloads'),
showToast(getString('novelScreen.deletedAllDownloads')),
);
});
};
Expand Down Expand Up @@ -383,7 +384,7 @@ export const deleteReadChaptersFromDb = async () => {
db.transaction(tx => {
tx.executeSql(updateIsDownloadedQuery, [], noop, txnErrorCallback);
});
showToast('Read chapters deleted');
showToast(getString('novelScreen.readChaptersDeleted'));
};

const bookmarkChapterQuery = 'UPDATE Chapter SET bookmark = ? WHERE id = ?';
Expand Down
3 changes: 2 additions & 1 deletion src/database/queries/HistoryQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { noop } from 'lodash-es';
const db = SQLite.openDatabase('lnreader.db');

import { showToast } from '../../utils/showToast';
import { getString } from '@strings/translations';

const getHistoryQuery = `
SELECT
Expand Down Expand Up @@ -57,5 +58,5 @@ export const deleteAllHistory = async () => {
db.transaction(tx => {
tx.executeSql('UPDATE CHAPTER SET readTime = NULL');
});
showToast('History deleted.');
showToast(getString('historyScreen.deleted'));
};
5 changes: 3 additions & 2 deletions src/database/queries/NovelQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const removeNovelsFromLibrary = (novelIds: Array<number>) => {
`DELETE FROM NovelCategory WHERE novelId IN (${novelIds.join(', ')});`,
);
});
showToast('Removed from Library');
showToast(getString('browseScreen.removeFromLibrary'));
};

export const getCachedNovels = (): Promise<NovelInfo[]> => {
Expand All @@ -175,7 +175,8 @@ export const deleteCachedNovels = async () => {
tx.executeSql(
'DELETE FROM Novel WHERE inLibrary = 0',
[],
() => showToast('Cached novels deleted'),
() =>
showToast(getString('advancedSettingsScreen.cachedNovelsDeletedToast')),
txnErrorCallback,
);
});
Expand Down
12 changes: 8 additions & 4 deletions src/database/tables/CategoryTable.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getString } from '@strings/translations';

export const createCategoriesTableQuery = `
CREATE TABLE IF NOT EXISTS Category (
id INTEGER PRIMARY KEY AUTOINCREMENT,
Expand All @@ -13,8 +15,10 @@ export const createCategoryTriggerQuery = `
END;
`;

export const createCategoryDefaultQuery =
'INSERT OR IGNORE INTO Category (id, name, sort) VALUES (1, "Default", 1)';
export const createCategoryDefaultQuery = `INSERT OR IGNORE INTO Category (id, name, sort) VALUES (1, "${getString(
'categories.default',
)}", 1)`;

export const createCategoryLocalQuery =
'INSERT OR IGNORE INTO Category (id, name, sort) VALUES (2, "Local", 2)';
export const createCategoryLocalQuery = `INSERT OR IGNORE INTO Category (id, name, sort) VALUES (2, "${getString(
'categories.local',
)}", 2)`;
23 changes: 15 additions & 8 deletions src/hooks/persisted/useDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChapterInfo, NovelInfo } from '@database/types';
import { BACKGROUND_ACTION, BackgoundAction } from '@services/constants';
import { MMKVStorage, getMMKVObject, setMMKVObject } from '@utils/mmkv/mmkv';
import { showToast } from '@utils/showToast';
import { getString } from '@strings/translations';
import BackgroundService from 'react-native-background-actions';
import { useMMKVObject } from 'react-native-mmkv';
import * as Notifications from 'expo-notifications';
Expand All @@ -27,8 +28,12 @@ const downloadChapterAction = async (taskData?: TaskData) => {
while (queue.length > 0) {
const { novel, chapter } = queue[0];
await BackgroundService.updateNotification({
taskTitle: `Downloading: ${novel.name}`,
taskDesc: `Chapter: ${chapter.name}`,
taskTitle: getString('downloadScreen.downloadingNovel', {
name: novel.name,
}),
taskDesc: getString('downloadScreen.chapterName', {
name: chapter.name,
}),
});
await downloadChapter(
novel.pluginId,
Expand All @@ -39,7 +44,9 @@ const downloadChapterAction = async (taskData?: TaskData) => {
Notifications.scheduleNotificationAsync({
content: {
title: chapter.name,
body: `Download failed: ${error.message}`,
body: getString('downloadScreen.failed', {
message: error.message,
}),
},
trigger: null,
}),
Expand All @@ -56,8 +63,8 @@ const downloadChapterAction = async (taskData?: TaskData) => {
MMKVStorage.delete(BACKGROUND_ACTION);
await Notifications.scheduleNotificationAsync({
content: {
title: 'Downloader',
body: 'Download completed',
title: getString('downloadScreen.downloader'),
body: getString('downloadScreen.completed'),
},
trigger: null,
});
Expand Down Expand Up @@ -91,16 +98,16 @@ export default function useDownload() {
if (!BackgroundService.isRunning()) {
BackgroundService.start(downloadChapterAction, {
taskName: 'Download chapters',
taskTitle: 'Downloading',
taskDesc: 'Preparing',
taskTitle: getString('downloadScreen.downloading'),
taskDesc: getString('common.preparing'),
taskIcon: { name: 'notification_icon', type: 'drawable' },
color: '#00adb5',
parameters: { delay: 1000 },
linkingURI: 'lnreader://updates',
});
}
} else {
showToast('Another service is running. Queued chapters');
showToast(getString('downloadScreen.serviceRunning'));
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/hooks/persisted/useNovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { showToast } from '@utils/showToast';
import { useCallback } from 'react';
import { NovelDownloadFolder } from '@utils/constants/download';
import * as RNFS from 'react-native-fs';
import { getString } from '@strings/translations';

// store key: PREFIX + '_' + novel.url,

Expand Down Expand Up @@ -301,7 +302,7 @@ export const useNovel = (url: string, pluginId: string) => {
};
}),
);
showToast(`Deleted ${_chapter.name}`);
showToast(getString('common.deleted', { name: _chapter.name }));
});
}
};
Expand All @@ -310,7 +311,11 @@ export const useNovel = (url: string, pluginId: string) => {
(_chaters: ChapterInfo[]) => {
if (novel) {
_deleteChapters(novel.pluginId, novel.id, _chaters).then(() => {
showToast(`Deleted ${_chaters.length} chapters`);
showToast(
getString('updatesScreen.deletedChapters', {
num: _chaters.length,
}),
);
setChapters(
chapters.map(chapter => {
if (_chaters.some(_c => _c.id === chapter.id)) {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/BrowseSourceScreen/BrowseSourceScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const BrowseSourceScreen = ({ route, navigation }: BrowseSourceScreenProps) => {
styles.filterFab,
{ backgroundColor: theme.primary, marginBottom: bottom },
]}
label={'Filter'}
label={getString('common.filter')}
uppercase={false}
color={theme.onPrimary}
onPress={() => filterSheetRef?.current?.present()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Picker } from '@react-native-picker/picker';
import { useBoolean } from '@hooks';
import { overlay } from 'react-native-paper';
import { getValueFor } from './filterUtils';
import { getString } from '@strings/translations';

const insertOrRemoveIntoArray = (array: string[], val: string): string[] =>
array.indexOf(val) > -1 ? array.filter(ele => ele !== val) : [...array, val];
Expand Down Expand Up @@ -249,14 +250,14 @@ const FilterBottomSheet: React.FC<BottomSheetProps> = ({
style={[styles.buttonContainer, { borderBottomColor: theme.outline }]}
>
<Button
title={'Reset'}
title={getString('common.reset')}
onPress={() => {
setSelectedFilters(filters);
clearFilters(filters);
}}
/>
<Button
title={'Filter'}
title={getString('common.filter')}
textColor={theme.onSurface}
onPress={() => {
setFilters(selectedFilters);
Expand Down
14 changes: 11 additions & 3 deletions src/screens/StatsScreen/StatsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@database/queries/StatsQueries';
import { Row } from '@components/Common';
import { overlay } from 'react-native-paper';
import { translateNovelStatus } from '@utils/translateEnum';

const StatsScreen = () => {
const theme = useTheme();
Expand Down Expand Up @@ -85,7 +86,7 @@ const StatsScreen = () => {
contentContainerStyle={styles.contentCtn}
>
<Text style={[styles.header, { color: theme.onSurfaceVariant }]}>
{getString('moreScreen.settingsScreen.generalSettings')}
{getString('generalSettings')}
</Text>
<Row style={styles.statsRow}>
<StatsCard
Expand All @@ -112,7 +113,10 @@ const StatsScreen = () => {
/>
</Row>
<Row style={styles.statsRow}>
<StatsCard label="Sources" value={stats.sourcesCount} />
<StatsCard
label={getString('statsScreen.sources')}
value={stats.sourcesCount}
/>
</Row>
<Text style={[styles.header, { color: theme.onSurfaceVariant }]}>
{getString('statsScreen.genreDistribution')}
Expand All @@ -127,7 +131,11 @@ const StatsScreen = () => {
</Text>
<Row style={[styles.statsRow, styles.genreRow]}>
{Object.entries(stats.status || {}).map(item => (
<StatsCard key={item[0]} label={item[0]} value={item[1]} />
<StatsCard
key={item[0]}
label={translateNovelStatus(item[0])}
value={item[1]}
/>
))}
</Row>
</ScrollView>
Expand Down
6 changes: 3 additions & 3 deletions src/screens/browse/BrowseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const BrowseScreen = ({ navigation }: BrowseScreenProps) => {
});
}
list.push({
header: 'Installed plugins',
header: getString('browseScreen.installedPlugins'),
data: filteredInstalledPlugins,
});
}
Expand All @@ -112,8 +112,8 @@ const BrowseScreen = ({ navigation }: BrowseScreenProps) => {

const [index, setIndex] = React.useState(0);
const [routes] = React.useState([
{ key: 'installedRoute', title: 'Installed' },
{ key: 'availableRoute', title: 'Available' },
{ key: 'installedRoute', title: getString('browseScreen.installed') },
{ key: 'availableRoute', title: getString('browseScreen.available') },
]);

return (
Expand Down
14 changes: 5 additions & 9 deletions src/screens/browse/BrowseSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const BrowseSettings = ({ navigation }: BrowseSettingsScreenProp) => {
return (
<>
<Appbar
title={getString('moreScreen.settingsScreen.browseSettings')}
title={getString('browseSettings')}
handleGoBack={goBack}
theme={theme}
/>
Expand All @@ -30,9 +30,7 @@ const BrowseSettings = ({ navigation }: BrowseSettingsScreenProp) => {
{getString('browseScreen.globalSearch')}
</List.SubHeader>
<List.InfoItem
title={getString(
'moreScreen.settingsScreen.browseSettingsScreen.searchAllWarning',
)}
title={getString('browseSettingsScreen.searchAllWarning')}
icon="information-outline"
theme={theme}
/>
Expand All @@ -41,13 +39,13 @@ const BrowseSettings = ({ navigation }: BrowseSettingsScreenProp) => {
{getString('browseScreen.discover')}
</List.SubHeader>
<SwitchItem
label="Show AniList"
label={`${getString('common.show')} AniList`}
value={showAniList}
onPress={() => setBrowseSettings({ showAniList: !showAniList })}
theme={theme}
/>
<SwitchItem
label="Show MyAnimeList"
label={`${getString('common.show')} MyAnimeList`}
value={showMyAnimeList}
onPress={() =>
setBrowseSettings({ showMyAnimeList: !showMyAnimeList })
Expand All @@ -56,9 +54,7 @@ const BrowseSettings = ({ navigation }: BrowseSettingsScreenProp) => {
/>
<List.Divider theme={theme} />
<List.SubHeader theme={theme}>
{getString(
'moreScreen.settingsScreen.browseSettingsScreen.languages',
)}
{getString('browseSettingsScreen.languages')}
</List.SubHeader>
</>
}
Expand Down
Loading
Loading