Skip to content

Commit 53ab6f8

Browse files
committed
feat(i18n): merge PR #4597/#4774 and finish localization audit
1 parent f8c596f commit 53ab6f8

File tree

48 files changed

+457
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+457
-103
lines changed

apps/desktop/layer/renderer/src/@types/default-resource.electron.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
// DONT EDIT THIS FILE MANUALLY
22
import ai_en from "@locales/ai/en.json"
3+
import ai_frFR from "@locales/ai/fr-FR.json"
34
import ai_ja from "@locales/ai/ja.json"
45
import en from "@locales/app/en.json"
6+
import app_frFR from "@locales/app/fr-FR.json"
57
import app_ja from "@locales/app/ja.json"
68
import app_zhCN from "@locales/app/zh-CN.json"
79
import app_zhTW from "@locales/app/zh-TW.json"
810
import common_en from "@locales/common/en.json"
11+
import common_frFR from "@locales/common/fr-FR.json"
912
import common_ja from "@locales/common/ja.json"
1013
import common_zhCN from "@locales/common/zh-CN.json"
1114
import common_zhTW from "@locales/common/zh-TW.json"
1215
import errors_en from "@locales/errors/en.json"
16+
import errors_frFR from "@locales/errors/fr-FR.json"
1317
import errors_ja from "@locales/errors/ja.json"
1418
import errors_zhCN from "@locales/errors/zh-CN.json"
1519
import errors_zhTW from "@locales/errors/zh-TW.json"
1620
import lang_en from "@locales/lang/en.json"
21+
import lang_frFR from "@locales/lang/fr-FR.json"
1722
import lang_ja from "@locales/lang/ja.json"
1823
import lang_zhCN from "@locales/lang/zh-CN.json"
1924
import lang_zhTW from "@locales/lang/zh-TW.json"
2025
import settings_en from "@locales/settings/en.json"
26+
import settings_frFR from "@locales/settings/fr-FR.json"
2127
import settings_ja from "@locales/settings/ja.json"
2228
import settings_zhCN from "@locales/settings/zh-CN.json"
2329
import settings_zhTW from "@locales/settings/zh-TW.json"
2430
import shortcuts_en from "@locales/shortcuts/en.json"
31+
import shortcuts_frFR from "@locales/shortcuts/fr-FR.json"
2532
import shortcuts_ja from "@locales/shortcuts/ja.json"
2633
import shortcuts_zhCN from "@locales/shortcuts/zh-CN.json"
2734
import shortcuts_zhTW from "@locales/shortcuts/zh-TW.json"
@@ -70,6 +77,15 @@ export const defaultResources = {
7077
errors: errors_zhTW,
7178
ai: ai_en, // Fallback to English until Traditional Chinese translation is available
7279
},
80+
"fr-FR": {
81+
app: app_frFR,
82+
lang: lang_frFR,
83+
common: common_frFR,
84+
settings: settings_frFR,
85+
shortcuts: shortcuts_frFR,
86+
errors: errors_frFR,
87+
ai: ai_frFR,
88+
},
7389
} satisfies Record<
7490
RendererSupportedLanguages,
7591
Partial<Record<(typeof ns)[number], Record<string, string>>>

apps/desktop/layer/renderer/src/modules/trending/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ const LanguageOptions = [
2525
label: "words.chinese",
2626
value: "cmn",
2727
},
28+
{
29+
label: "words.french",
30+
value: "fra",
31+
},
2832
]
2933

30-
type Language = "all" | "eng" | "cmn"
34+
type Language = "all" | "eng" | "cmn" | "fra"
3135

3236
type View = "all" | string
3337

@@ -64,6 +68,7 @@ export function Trending({
6468
const { t: tCommon } = useTranslation("common")
6569
const lang = useUISettingKey("discoverLanguage")
6670
const { onUpdateMaxScroll } = useScrollElementUpdate()
71+
const trendingLanguage = lang === "fra" ? "eng" : lang
6772

6873
const [selectedView, setSelectedView] = useState<View>("all")
6974
const viewOptions = useMemo(() => buildViewOptions(), [])
@@ -72,7 +77,7 @@ export function Trending({
7277
queryKey: ["trending", lang, selectedView],
7378
queryFn: async () => {
7479
return await followClient.api.trending.getFeeds({
75-
language: lang === "all" ? undefined : lang,
80+
language: trendingLanguage === "all" ? undefined : trendingLanguage,
7681
view: selectedView === "all" ? undefined : Number(selectedView),
7782
limit,
7883
})

apps/desktop/layer/renderer/src/pages/(main)/(layer)/(subview)/discover/category/[category].tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const LanguageMap = {
2626
all: "all",
2727
eng: "en",
2828
cmn: "zh-CN",
29+
fra: "fr-FR",
2930
} as const
3031

3132
export const Component = () => {
@@ -134,7 +135,7 @@ export const Component = () => {
134135
) : items.length > 0 ? (
135136
<div className="w-full px-8 pb-8 pt-4">
136137
<Input
137-
placeholder="Search"
138+
placeholder={t("words.search", { ns: "common" })}
138139
className="mb-4"
139140
value={search}
140141
onChange={(e) => {
@@ -162,12 +163,10 @@ export const Component = () => {
162163
<EmptyIcon />
163164
</div>
164165
<p className="text-title2 text-text">
165-
{t("common.noContent", { defaultValue: "No content found in this category" })}
166+
{t("discover.empty.no_content", { ns: "common" })}
166167
</p>
167168
<p className="mt-2 text-body text-text-secondary">
168-
{t("discover.tryAnotherCategory", {
169-
defaultValue: "Try selecting another category or language",
170-
})}
169+
{t("discover.empty.try_another_category_or_language", { ns: "common" })}
171170
</p>
172171
</div>
173172
)}

apps/mobile/src/components/errors/GlobalErrorScreen.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { applicationName } from "expo-application"
22
import * as React from "react"
3+
import { useTranslation } from "react-i18next"
34
import { TouchableOpacity, View } from "react-native"
45

56
import { Text } from "@/src/components/ui/typography/Text"
@@ -9,22 +10,23 @@ interface GlobalErrorScreenProps {
910
resetError?: () => void
1011
}
1112
export const GlobalErrorScreen: React.FC<GlobalErrorScreenProps> = ({ error, resetError }) => {
13+
const { t } = useTranslation("common")
1214
return (
1315
<View className="flex-1 bg-system-background">
1416
<View className="flex-1 items-center justify-center px-6">
1517
<Text className="mb-6 text-[64px]">😕</Text>
1618
<Text className="mb-3 text-center text-xl font-semibold text-label">
17-
{applicationName} crashed!
19+
{t("error_screen.crashed", { appName: applicationName ?? "App" })}
1820
</Text>
1921
<Text className="mb-8 text-center text-lg text-secondary-label">
20-
{error?.message || "An unexpected error occurred."}
22+
{error?.message || t("error_screen.unexpected")}
2123
</Text>
2224
{resetError && (
2325
<TouchableOpacity
2426
className="min-w-[160px] rounded-xl bg-accent px-6 py-3"
2527
onPress={resetError}
2628
>
27-
<Text className="text-center text-[17px] font-semibold text-white">Try Again</Text>
29+
<Text className="text-center text-[17px] font-semibold text-white">{t("retry")}</Text>
2830
</TouchableOpacity>
2931
)}
3032
</View>

apps/mobile/src/components/errors/ListErrorView.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslation } from "react-i18next"
12
import { TouchableOpacity, View } from "react-native"
23
import { useColor } from "react-native-uikit-colors"
34

@@ -7,6 +8,7 @@ import { AlertCuteFiIcon } from "@/src/icons/alert_cute_fi"
78
import { MonoText } from "../ui/typography/MonoText"
89

910
export const ListErrorView = ({ error, resetError }: { error: Error; resetError: () => void }) => {
11+
const { t } = useTranslation("common")
1012
const red = useColor("red")
1113
return (
1214
<View className="flex-1 items-center justify-center p-4">
@@ -15,17 +17,17 @@ export const ListErrorView = ({ error, resetError }: { error: Error; resetError:
1517
<AlertCuteFiIcon color={red} height={48} width={48} />
1618
</View>
1719
<Text className="mb-2 text-center text-lg font-semibold text-label">
18-
Unable to Load Content
20+
{t("error_screen.list_unable_to_load")}
1921
</Text>
2022
<Text className="mb-2 text-center text-base text-secondary-label">
21-
There was a problem loading the list. Please try again later.
23+
{t("error_screen.list_try_later")}
2224
</Text>
2325
<MonoText className="mb-4 text-center text-base text-secondary-label">
24-
{error.message || "Unknown Error"}
26+
{error.message || t("error_screen.unknown")}
2527
</MonoText>
2628

2729
<TouchableOpacity className="w-full rounded-xl bg-accent px-6 py-3" onPress={resetError}>
28-
<Text className="text-center text-base font-semibold text-white">Try Again</Text>
30+
<Text className="text-center text-base font-semibold text-white">{t("retry")}</Text>
2931
</TouchableOpacity>
3032
</View>
3133
</View>

apps/mobile/src/components/errors/ScreenErrorScreen.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from "react"
2+
import { useTranslation } from "react-i18next"
23
import { TouchableOpacity, View } from "react-native"
34

45
import { Text } from "@/src/components/ui/typography/Text"
@@ -9,17 +10,18 @@ interface ScreenErrorScreenProps {
910
resetError?: () => void
1011
}
1112
export const ScreenErrorScreen: React.FC<ScreenErrorScreenProps> = ({ error }) => {
13+
const { t } = useTranslation("common")
1214
const navigation = useNavigation()
1315
const canGoBack = useCanBack()
1416
return (
1517
<View className="flex-1 bg-system-background">
1618
<View className="flex-1 items-center justify-center px-6">
1719
<Text className="mb-6 text-[64px]">😕</Text>
1820
<Text className="mb-3 text-center text-xl font-semibold text-label">
19-
This page went wrong, go back and try again.
21+
{t("error_screen.page_failed")}
2022
</Text>
2123
<Text className="mb-8 text-center text-lg text-secondary-label">
22-
{error?.message || "An unexpected error occurred."}
24+
{error?.message || t("error_screen.unexpected")}
2325
</Text>
2426

2527
<View className="flex-row gap-4">
@@ -28,7 +30,9 @@ export const ScreenErrorScreen: React.FC<ScreenErrorScreenProps> = ({ error }) =
2830
className="min-w-[160px] rounded-xl bg-accent px-6 py-3"
2931
onPress={() => navigation.back()}
3032
>
31-
<Text className="text-center text-[17px] font-semibold text-white">Go Back </Text>
33+
<Text className="text-center text-[17px] font-semibold text-white">
34+
{t("words.back")}
35+
</Text>
3236
</TouchableOpacity>
3337
)}
3438
</View>

apps/mobile/src/modules/ai/summary.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const AISummary: FC<{
9595
const upgradeTitle = t("ai.summary_upgrade_required_title")
9696
const upgradeDescription = t("ai.summary_upgrade_required_description")
9797
const upgradeCTA = t("ai.summary_upgrade_view_plans")
98+
const summaryTitle = t("entry_actions.toggle_ai_summary")
9899
const handleUpgradePress = () => {
99100
void Haptics.selectionAsync()
100101
void navigateToPlanScreen()
@@ -163,12 +164,12 @@ export const AISummary: FC<{
163164
<MaskedView
164165
maskElement={
165166
<View className="bg-transparent">
166-
<Text className="text-[15px] font-semibold">AI Summary</Text>
167+
<Text className="text-[15px] font-semibold">{summaryTitle}</Text>
167168
</View>
168169
}
169170
>
170171
<LinearGradient colors={["#9333ea", "#2563eb"]} start={[0, 0]} end={[1, 0]}>
171-
<Text className="text-[15px] font-semibold text-transparent">AI Summary</Text>
172+
<Text className="text-[15px] font-semibold text-transparent">{summaryTitle}</Text>
172173
</LinearGradient>
173174
</MaskedView>
174175
</View>
@@ -177,7 +178,7 @@ export const AISummary: FC<{
177178
onPress={() => {
178179
Clipboard.setString(summaryTextForSheet)
179180
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success)
180-
toast.success("Copied to clipboard")
181+
toast.success(t("app.copied_to_clipboard", { ns: "common" }))
181182
}}
182183
onLongPress={() => setSheetOpen(true)}
183184
className="rounded-full bg-quaternary-system-fill p-1.5 active:opacity-70"
@@ -230,6 +231,7 @@ const ErrorContent = ({
230231
message: string
231232
onRetry?: () => void
232233
}) => {
234+
const { t } = useTranslation()
233235
return (
234236
<View className="mt-3">
235237
<View className="flex-row items-center gap-2">
@@ -238,14 +240,18 @@ const ErrorContent = ({
238240
{onRetry &&
239241
(forMeasurement ? (
240242
<View className="mt-3 self-start rounded-full bg-quaternary-system-fill px-4 py-2">
241-
<Text className="text-[14px] font-medium text-label">Retry</Text>
243+
<Text className="text-[14px] font-medium text-label">
244+
{t("retry", { ns: "common" })}
245+
</Text>
242246
</View>
243247
) : (
244248
<Pressable
245249
onPress={onRetry}
246250
className="mt-3 self-start rounded-full bg-quaternary-system-fill px-4 py-2"
247251
>
248-
<Text className="text-[14px] font-medium text-label">Retry</Text>
252+
<Text className="text-[14px] font-medium text-label">
253+
{t("retry", { ns: "common" })}
254+
</Text>
249255
</Pressable>
250256
))}
251257
</View>
@@ -312,6 +318,7 @@ const SelectableTextSheet: FC<{
312318
onClose: () => void
313319
text: string
314320
}> = ({ visible, onClose, text }) => {
321+
const { t } = useTranslation()
315322
const insets = useSafeAreaInsets()
316323
const textColor = useColor("label")
317324
const handleCopyAll = () => {
@@ -334,7 +341,9 @@ const SelectableTextSheet: FC<{
334341
>
335342
<CopyCuteReIcon width={18} height={18} color={textColor} />
336343
</TouchableOpacity>
337-
<Text className="text-lg font-semibold text-label">AI Summary</Text>
344+
<Text className="text-lg font-semibold text-label">
345+
{t("entry_actions.toggle_ai_summary")}
346+
</Text>
338347
<TouchableOpacity
339348
onPress={onClose}
340349
className="rounded-full bg-zinc-100 p-2 active:opacity-80 dark:bg-zinc-800"

apps/mobile/src/modules/discover/Category.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ import { DiscoverSettingsScreen } from "@/src/screens/(modal)/DiscoverSettingsSc
1818
import { RecommendationCategoryScreen } from "@/src/screens/(stack)/recommendation/RecommendationCategoryScreen"
1919

2020
export const Category = () => {
21+
const { t } = useTranslation("common")
2122
const navigation = useNavigation()
2223
const label = useColor("label")
2324
return (
2425
<>
2526
<View className="mt-4 flex-row items-center justify-between pb-1 pl-6 pr-5 pt-4">
2627
<View className="flex-row items-center gap-2">
2728
<Grid2CuteReIcon width={24} height={24} color={label} />
28-
<Text className="pb-2 text-2xl font-bold leading-[1.1] text-label">Categories</Text>
29+
<Text className="pb-2 text-2xl font-bold leading-[1.1] text-label">
30+
{t("words.categories")}
31+
</Text>
2932
</View>
3033
<ItemPressable
3134
className="rounded-lg p-1"

apps/mobile/src/modules/discover/Recommendations.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ export const Recommendations = () => {
131131
</View>
132132
)
133133
}
134-
const LanguageMap = {
135-
all: "all",
136-
eng: "en",
137-
cmn: "zh-CN",
138-
} as const
139134
export const RecommendationTab: TabComponent<{
140135
contentContainerStyle?: StyleProp<ViewStyle>
141136
insets?: {
@@ -151,11 +146,11 @@ export const RecommendationTab: TabComponent<{
151146
insets: customInsets,
152147
...rest
153148
}) => {
149+
const { t } = useTranslation("common")
154150
const discoverLanguage = useUISettingKey("discoverLanguage")
155151
const { data, isLoading } = useQuery({
156152
queryKey: ["rsshub-popular", tab.value, discoverLanguage],
157-
queryFn: () =>
158-
fetchRsshubPopular(tab.value, LanguageMap[discoverLanguage]).then((res) => res.data),
153+
queryFn: () => fetchRsshubPopular(tab.value, discoverLanguage).then((res) => res.data),
159154
staleTime: 1000 * 60 * 60 * 24,
160155
// 1 day
161156
meta: {
@@ -164,7 +159,7 @@ export const RecommendationTab: TabComponent<{
164159
})
165160
const { data: analysisData, isLoading: isAnalysisLoading } = useQuery({
166161
queryKey: ["rsshub-analysis", discoverLanguage],
167-
queryFn: () => fetchRsshubAnalysis(LanguageMap[discoverLanguage]).then((res) => res.data),
162+
queryFn: () => fetchRsshubAnalysis(discoverLanguage).then((res) => res.data),
168163
staleTime: 1000 * 60 * 60 * 24,
169164
// 1 day
170165
meta: {
@@ -259,7 +254,7 @@ export const RecommendationTab: TabComponent<{
259254
if (keys.length === 0) {
260255
return (
261256
<View className="flex-1 items-center justify-center">
262-
<Text className="text-secondary-label">This is a barren wasteland of knowledge.</Text>
257+
<Text className="text-secondary-label">{t("search.empty.no_results")}</Text>
263258
</View>
264259
)
265260
}

0 commit comments

Comments
 (0)