Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(mobile): extract hard-coded string for i18n (#1481)

Corentin Thomassetf65c353f2f5a
diff --git a/apps/mobile/app/(app)/(with-organizations)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(with-organizations)/(tabs)/_layout.tsx
index d8f96993..161267d1 100644
--- a/apps/mobile/app/(app)/(with-organizations)/(tabs)/_layout.tsx
+++ b/apps/mobile/app/(app)/(with-organizations)/(tabs)/_layout.tsx
@@ -31,7 +31,7 @@ export default function TabLayout() {
<Tabs.Screen
name="list"
options={{
- title: 'Documents',
+ title: t.documents.title,
tabBarIcon: ({ color }) => (
<Icon name="home" size={30} color={color} style={{ height: 30 }} />
),
@@ -41,7 +41,7 @@ export default function TabLayout() {
<Tabs.Screen
name="search"
options={{
- title: 'Search',
+ title: t.documents.search.title,
tabBarIcon: ({ color }) => (
<Icon name="search" size={30} color={color} style={{ height: 30 }} />
),
@@ -51,7 +51,7 @@ export default function TabLayout() {
<Tabs.Screen
name="import"
options={{
- title: 'Import',
+ title: t.documents.import.title,
tabBarButton: () => <ImportTabButton />,
tabBarLabel: () => null,
}}
diff --git a/apps/mobile/app/+not-found.tsx b/apps/mobile/app/+not-found.tsx
index a69f55c1..4b923634 100644
--- a/apps/mobile/app/+not-found.tsx
+++ b/apps/mobile/app/+not-found.tsx
@@ -1,18 +1,20 @@
import { Link, Stack } from 'expo-router';
import { StyleSheet, Text, useColorScheme, View } from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
export default function NotFoundScreen() {
+ const t = useAppTranslations();
const colorScheme = useColorScheme();
const isDark = colorScheme === 'dark';
const styles = createStylesNotFound(isDark);
return (
<>
- <Stack.Screen options={{ title: 'Oops!' }} />
+ <Stack.Screen options={{ title: t.navigation.notFoundTitle }} />
<View style={styles.container}>
- <Text style={styles.title}>This screen doesn&apos;t exist.</Text>
+ <Text style={styles.title}>{t.navigation.notFoundMessage}</Text>
<Link href="/" style={styles.link}>
- <Text style={styles.linkText}>Go to home screen</Text>
+ <Text style={styles.linkText}>{t.navigation.goHome}</Text>
</Link>
</View>
</>
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
index bbb268db..ad919426 100644
--- a/apps/mobile/app/_layout.tsx
+++ b/apps/mobile/app/_layout.tsx
@@ -4,6 +4,7 @@ import * as SplashScreen from 'expo-splash-screen';
import { useEffect } from 'react';
import { ShareIntentProvider } from 'expo-share-intent';
import { StatusBar } from 'expo-status-bar';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { AppProviders } from '@/modules/app/providers/app-providers';
import { ShareIntentHandler } from '@/modules/documents/components/share-intent-handler';
@@ -23,6 +24,7 @@ export default function RootLayout() {
}
function LocalizedLayout() {
+ const t = useAppTranslations();
const colorScheme = useColorScheme();
useEffect(() => {
@@ -41,7 +43,10 @@ function LocalizedLayout() {
name="app-settings"
options={{ presentation: 'modal', headerShown: false }}
/>
- <Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
+ <Stack.Screen
+ name="modal"
+ options={{ presentation: 'modal', title: t.navigation.modalTitle }}
+ />
</Stack>
<ShareIntentHandler />
<StatusBar style="auto" />
diff --git a/apps/mobile/app/modal.tsx b/apps/mobile/app/modal.tsx
index 51b55f01..a0a6259f 100644
--- a/apps/mobile/app/modal.tsx
+++ b/apps/mobile/app/modal.tsx
@@ -1,6 +1,7 @@
import { Link } from 'expo-router';
import { StyleSheet } from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { ThemedText } from '@/modules/ui/components/themed-text';
import { ThemedView } from '@/modules/ui/components/themed-view';
@@ -18,11 +19,12 @@ const styles = StyleSheet.create({
});
export default function ModalScreen() {
+ const t = useAppTranslations();
return (
<ThemedView style={styles.container}>
- <ThemedText type="title">This is a modal</ThemedText>
+ <ThemedText type="title">{t.navigation.modalMessage}</ThemedText>
<Link href="/" dismissTo style={styles.link}>
- <ThemedText type="link">Go to home screen</ThemedText>
+ <ThemedText type="link">{t.navigation.goHome}</ThemedText>
</Link>
</ThemedView>
);
diff --git a/apps/mobile/src/modules/auth/components/two-factor-verification.tsx b/apps/mobile/src/modules/auth/components/two-factor-verification.tsx
index 11a7c8d5..1b00909c 100644
--- a/apps/mobile/src/modules/auth/components/two-factor-verification.tsx
+++ b/apps/mobile/src/modules/auth/components/two-factor-verification.tsx
@@ -9,6 +9,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useAuthClient } from '@/modules/api/providers/api.provider';
import { useAlert } from '@/modules/ui/providers/alert-provider';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
@@ -22,6 +23,7 @@ export function TwoFactorVerificationForm({
onSuccess: () => void;
onBack: () => void;
}) {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const authClient = useAuthClient();
const { showAlert } = useAlert();
@@ -47,8 +49,8 @@ export function TwoFactorVerificationForm({
onSuccess();
} catch (error) {
showAlert({
- title: 'Verification Failed',
- message: error instanceof Error ? error.message : 'An error occurred',
+ title: t.auth.twoFactor.failed,
+ message: error instanceof Error ? error.message : t.common.anErrorOccurred,
});
} finally {
setIsVerifying(false);
@@ -71,15 +73,21 @@ export function TwoFactorVerificationForm({
return (
<View style={styles.formContainer}>
<View style={styles.fieldContainer}>
- <Text style={styles.label}>{useBackupCode ? 'Backup code' : 'Verification code'}</Text>
+ <Text style={styles.label}>
+ {useBackupCode ? t.auth.twoFactor.backupCode : t.auth.twoFactor.verificationCode}
+ </Text>
<Text style={styles.description}>
{useBackupCode
- ? 'Enter one of your backup codes'
- : 'Enter the 6-digit code from your authenticator app'}
+ ? t.auth.twoFactor.backupDescription
+ : t.auth.twoFactor.verificationDescription}
</Text>
<TextInput
style={styles.input}
- placeholder={useBackupCode ? 'Enter a backup code' : '000000'}
+ placeholder={
+ useBackupCode
+ ? t.auth.twoFactor.backupPlaceholder
+ : t.auth.twoFactor.verificationPlaceholder
+ }
placeholderTextColor={themeColors.mutedForeground}
value={code}
onChangeText={handleCodeChange}
@@ -94,7 +102,7 @@ export function TwoFactorVerificationForm({
</View>
<View style={styles.trustDeviceRow}>
- <Text style={styles.trustDeviceLabel}>Trust this device</Text>
+ <Text style={styles.trustDeviceLabel}>{t.auth.twoFactor.trustDevice}</Text>
<Switch
value={trustDevice}
onValueChange={setTrustDevice}
@@ -111,18 +119,18 @@ export function TwoFactorVerificationForm({
{isVerifying ? (
<ActivityIndicator color={themeColors.primaryForeground} />
) : (
- <Text style={styles.buttonText}>Verify</Text>
+ <Text style={styles.buttonText}>{t.auth.twoFactor.verify}</Text>
)}
</TouchableOpacity>
<TouchableOpacity style={styles.linkButton} onPress={switchCodeMode} disabled={isVerifying}>
<Text style={styles.linkText}>
- {useBackupCode ? 'Use an authenticator code' : 'Use a backup code'}
+ {useBackupCode ? t.auth.twoFactor.useAuthenticator : t.auth.twoFactor.useBackupCode}
</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.linkButton} onPress={onBack} disabled={isVerifying}>
- <Text style={styles.linkText}>Back to login</Text>
+ <Text style={styles.linkText}>{t.auth.twoFactor.backToLogin}</Text>
</TouchableOpacity>
</View>
);
diff --git a/apps/mobile/src/modules/auth/screens/login.screen.tsx b/apps/mobile/src/modules/auth/screens/login.screen.tsx
index 30bc5d27..2554c30c 100644
--- a/apps/mobile/src/modules/auth/screens/login.screen.tsx
+++ b/apps/mobile/src/modules/auth/screens/login.screen.tsx
@@ -15,6 +15,7 @@ import {
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import * as v from 'valibot';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useAuthClient } from '@/modules/api/providers/api.provider';
import { useAlert } from '@/modules/ui/providers/alert-provider';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
@@ -23,12 +24,13 @@ import { getEnabledOAuthProviders } from '../auth.models';
import { AuthNavigation } from '../components/auth-navigation';
import { TwoFactorVerificationForm } from '../components/two-factor-verification';
-const loginSchema = v.object({
- email: v.pipe(v.string(), v.email('Please enter a valid email')),
- password: v.pipe(v.string(), v.minLength(8, 'Password must be at least 8 characters')),
-});
-
export function LoginScreen() {
+ const t = useAppTranslations();
+ const loginSchema = v.object({
+ email: v.pipe(v.string(), v.email(t.auth.validation.email)),
+ password: v.pipe(v.string(), v.minLength(8, t.auth.validation.password)),
+ });
+
const router = useRouter();
const themeColors = useThemeColor();
const authClient = useAuthClient();
@@ -73,8 +75,8 @@ export function LoginScreen() {
router.replace('/(app)/(with-organizations)/(tabs)/list');
} catch (error) {
showAlert({
- title: 'Login Failed',
- message: error instanceof Error ? error.message : 'An error occurred',
+ title: t.auth.login.failed,
+ message: error instanceof Error ? error.message : t.common.anErrorOccurred,
});
} finally {
setIsSubmitting(false);
@@ -90,8 +92,8 @@ export function LoginScreen() {
}
} catch (error) {
showAlert({
- title: 'Sign In Failed',
- message: error instanceof Error ? error.message : 'An error occurred',
+ title: t.auth.login.socialFailed,
+ message: error instanceof Error ? error.message : t.common.anErrorOccurred,
});
}
};
@@ -127,8 +129,8 @@ export function LoginScreen() {
keyboardShouldPersistTaps="handled"
>
<View style={styles.header}>
- <Text style={styles.title}>Two-Factor Authentication</Text>
- <Text style={styles.subtitle}>Verify your identity to continue</Text>
+ <Text style={styles.title}>{t.auth.twoFactor.title}</Text>
+ <Text style={styles.subtitle}>{t.auth.twoFactor.subtitle}</Text>
</View>
<TwoFactorVerificationForm
@@ -149,8 +151,8 @@ export function LoginScreen() {
<AuthNavigation disabled={isSubmitting} />
<View style={styles.header}>
- <Text style={styles.title}>Welcome Back</Text>
- <Text style={styles.subtitle}>Sign in to your account</Text>
+ <Text style={styles.title}>{t.auth.login.title}</Text>
+ <Text style={styles.subtitle}>{t.auth.login.subtitle}</Text>
</View>
{isEmailEnabled && (
@@ -158,10 +160,10 @@ export function LoginScreen() {
<form.Field name="email">
{(field) => (
<View style={styles.fieldContainer}>
- <Text style={styles.label}>Email</Text>
+ <Text style={styles.label}>{t.common.email}</Text>
<TextInput
style={styles.input}
- placeholder="[email protected]"
+ placeholder={t.auth.emailPlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={field.state.value}
onChangeText={field.handleChange}
@@ -178,10 +180,10 @@ export function LoginScreen() {
<form.Field name="password">
{(field) => (
<View style={styles.fieldContainer}>
- <Text style={styles.label}>Password</Text>
+ <Text style={styles.label}>{t.auth.password}</Text>
<TextInput
style={styles.input}
- placeholder="Enter your password"
+ placeholder={t.auth.login.passwordPlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={field.state.value}
onChangeText={field.handleChange}
@@ -201,7 +203,7 @@ export function LoginScreen() {
{isSubmitting ? (
<ActivityIndicator color={themeColors.primaryForeground} />
) : (
- <Text style={styles.buttonText}>Sign In</Text>
+ <Text style={styles.buttonText}>{t.auth.login.submit}</Text>
)}
</TouchableOpacity>
</View>
@@ -212,7 +214,7 @@ export function LoginScreen() {
{isEmailEnabled && (
<View style={styles.divider}>
<View style={styles.dividerLine} />
- <Text style={styles.dividerText}>OR</Text>
+ <Text style={styles.dividerText}>{t.auth.login.or}</Text>
<View style={styles.dividerLine} />
</View>
)}
@@ -225,7 +227,7 @@ export function LoginScreen() {
onPress={async () => handleSocialSignIn(provider.providerId)}
>
<Text style={styles.socialButtonText}>
- {`Continue with ${provider.providerName}`}
+ {t.auth.login.continueWith({ name: provider.providerName })}
</Text>
</TouchableOpacity>
))}
@@ -235,7 +237,7 @@ export function LoginScreen() {
{authConfig?.isRegistrationEnabled === true && (
<TouchableOpacity style={styles.linkButton} onPress={() => router.push('/auth/signup')}>
- <Text style={styles.linkText}>Don&apos;t have an account? Sign up</Text>
+ <Text style={styles.linkText}>{t.auth.login.signupLink}</Text>
</TouchableOpacity>
)}
</ScrollView>
diff --git a/apps/mobile/src/modules/auth/screens/signup.screen.tsx b/apps/mobile/src/modules/auth/screens/signup.screen.tsx
index d5ec14d8..eef7f6e6 100644
--- a/apps/mobile/src/modules/auth/screens/signup.screen.tsx
+++ b/apps/mobile/src/modules/auth/screens/signup.screen.tsx
@@ -15,19 +15,21 @@ import {
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import * as v from 'valibot';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useAuthClient } from '@/modules/api/providers/api.provider';
import { useAlert } from '@/modules/ui/providers/alert-provider';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
import { useServerConfig } from '../../config/hooks/use-server-config';
import { AuthNavigation } from '../components/auth-navigation';
-const signupSchema = v.object({
- name: v.pipe(v.string(), v.minLength(1, 'Name is required')),
- email: v.pipe(v.string(), v.email('Please enter a valid email')),
- password: v.pipe(v.string(), v.minLength(8, 'Password must be at least 8 characters')),
-});
-
export function SignupScreen() {
+ const t = useAppTranslations();
+ const signupSchema = v.object({
+ name: v.pipe(v.string(), v.minLength(1, t.auth.validation.name)),
+ email: v.pipe(v.string(), v.email(t.auth.validation.email)),
+ password: v.pipe(v.string(), v.minLength(8, t.auth.validation.password)),
+ });
+
const router = useRouter();
const themeColors = useThemeColor();
const authClient = useAuthClient();
@@ -58,18 +60,17 @@ export function SignupScreen() {
if (isEmailVerificationRequired) {
showAlert({
- title: 'Check your email',
- message:
- 'We sent you a verification link. Please check your email to verify your account.',
- buttons: [{ text: 'OK', onPress: () => router.replace('/auth/login') }],
+ title: t.auth.signup.checkEmail,
+ message: t.auth.signup.verificationSent,
+ buttons: [{ text: t.common.ok, onPress: () => router.replace('/auth/login') }],
});
} else {
router.replace('/(app)/(with-organizations)/(tabs)/list');
}
} catch (error) {
showAlert({
- title: 'Signup Failed',
- message: error instanceof Error ? error.message : 'An error occurred',
+ title: t.auth.signup.failed,
+ message: error instanceof Error ? error.message : t.common.anErrorOccurred,
});
} finally {
setIsSubmitting(false);
@@ -101,9 +102,9 @@ export function SignupScreen() {
<ScrollView contentContainerStyle={styles.scrollContent}>
<AuthNavigation />
<View style={styles.centerContent}>
- <Text style={styles.errorText}>Registration is currently disabled</Text>
+ <Text style={styles.errorText}>{t.auth.signup.disabled}</Text>
<TouchableOpacity style={styles.linkButton} onPress={() => router.back()}>
- <Text style={styles.linkText}>Go back to login</Text>
+ <Text style={styles.linkText}>{t.auth.signup.backToLogin}</Text>
</TouchableOpacity>
</View>
</ScrollView>
@@ -120,18 +121,18 @@ export function SignupScreen() {
<AuthNavigation disabled={isSubmitting} />
<View style={styles.header}>
- <Text style={styles.title}>Create Account</Text>
- <Text style={styles.subtitle}>Sign up to get started</Text>
+ <Text style={styles.title}>{t.auth.signup.title}</Text>
+ <Text style={styles.subtitle}>{t.auth.signup.subtitle}</Text>
</View>
<View style={styles.formContainer}>
<form.Field name="name">
{(field) => (
<View style={styles.fieldContainer}>
- <Text style={styles.label}>Name</Text>
+ <Text style={styles.label}>{t.common.name}</Text>
<TextInput
style={styles.input}
- placeholder="Your name"
+ placeholder={t.auth.signup.namePlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={field.state.value}
onChangeText={field.handleChange}
@@ -146,10 +147,10 @@ export function SignupScreen() {
<form.Field name="email">
{(field) => (
<View style={styles.fieldContainer}>
- <Text style={styles.label}>Email</Text>
+ <Text style={styles.label}>{t.common.email}</Text>
<TextInput
style={styles.input}
- placeholder="[email protected]"
+ placeholder={t.auth.emailPlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={field.state.value}
onChangeText={field.handleChange}
@@ -166,10 +167,10 @@ export function SignupScreen() {
<form.Field name="password">
{(field) => (
<View style={styles.fieldContainer}>
- <Text style={styles.label}>Password</Text>
+ <Text style={styles.label}>{t.auth.password}</Text>
<TextInput
style={styles.input}
- placeholder="At least 8 characters"
+ placeholder={t.auth.signup.passwordPlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={field.state.value}
onChangeText={field.handleChange}
@@ -189,13 +190,13 @@ export function SignupScreen() {
{isSubmitting ? (
<ActivityIndicator color={themeColors.primaryForeground} />
) : (
- <Text style={styles.buttonText}>Sign Up</Text>
+ <Text style={styles.buttonText}>{t.auth.signup.submit}</Text>
)}
</TouchableOpacity>
</View>
<TouchableOpacity style={styles.linkButton} onPress={() => router.back()}>
- <Text style={styles.linkText}>Already have an account? Sign in</Text>
+ <Text style={styles.linkText}>{t.auth.signup.loginLink}</Text>
</TouchableOpacity>
</ScrollView>
</KeyboardAvoidingView>
diff --git a/apps/mobile/src/modules/documents/components/document-action-sheet.tsx b/apps/mobile/src/modules/documents/components/document-action-sheet.tsx
index fc8f6a06..191f13be 100644
--- a/apps/mobile/src/modules/documents/components/document-action-sheet.tsx
+++ b/apps/mobile/src/modules/documents/components/document-action-sheet.tsx
@@ -15,6 +15,7 @@ import {
TouchableWithoutFeedback,
View,
} from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient, useAuthClient } from '@/modules/api/providers/api.provider';
import { RenameDocumentDialog } from '@/modules/documents/components/rename-document-dialog';
import {
@@ -43,6 +44,7 @@ export function DocumentActionSheet({
excludedActions = [],
onDeleted,
}: DocumentActionSheetProps) {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const styles = createStyles({ themeColors });
const { showAlert } = useAlert();
@@ -81,8 +83,8 @@ export function DocumentActionSheet({
const canShare = await Sharing.isAvailableAsync();
if (!canShare) {
showAlert({
- title: 'Sharing Failed',
- message: 'Sharing is not available on this device. Please share the document manually.',
+ title: t.documents.sharingFailed,
+ message: t.documents.sharingUnavailable,
});
return;
}
@@ -97,8 +99,8 @@ export function DocumentActionSheet({
await Sharing.shareAsync(fileUri);
} catch {
showAlert({
- title: 'Error',
- message: 'Failed to download document file',
+ title: t.common.error,
+ message: t.documents.downloadFailed,
});
}
};
@@ -135,8 +137,8 @@ export function DocumentActionSheet({
});
} catch {
showAlert({
- title: 'Error',
- message: 'Failed to rename document',
+ title: t.common.error,
+ message: t.documents.renameFailed,
});
}
};
@@ -145,12 +147,12 @@ export function DocumentActionSheet({
onClose();
showAlert({
- title: 'Delete Document',
- message: `Are you sure you want to delete "${document.name}"? It will be moved to the trash.`,
+ title: t.documents.deleteTitle,
+ message: t.documents.deleteConfirmation({ name: document.name }),
buttons: [
- { text: 'Cancel', style: 'cancel' },
+ { text: t.common.cancel, style: 'cancel' },
{
- text: 'Delete',
+ text: t.common.delete,
style: 'destructive',
onPress: async () => {
try {
@@ -167,8 +169,8 @@ export function DocumentActionSheet({
onDeleted?.();
} catch {
showAlert({
- title: 'Error',
- message: 'Failed to delete document',
+ title: t.common.error,
+ message: t.documents.deleteFailed,
});
}
},
@@ -192,25 +194,25 @@ export function DocumentActionSheet({
}[] = [
{
key: 'view',
- label: 'View document',
+ label: t.documents.view,
icon: 'eye',
onPress: handleView,
},
{
key: 'rename',
- label: 'Rename',
+ label: t.documents.rename,
icon: 'edit-2',
onPress: handleRename,
},
{
key: 'share',
- label: 'Share',
+ label: t.common.share,
icon: 'share',
onPress: handleDownloadAndShare,
},
{
key: 'delete',
- label: 'Delete',
+ label: t.common.delete,
icon: 'trash-2',
onPress: handleDelete,
destructive: true,
diff --git a/apps/mobile/src/modules/documents/components/import-drawer.tsx b/apps/mobile/src/modules/documents/components/import-drawer.tsx
index 31da75f4..c8fe098a 100644
--- a/apps/mobile/src/modules/documents/components/import-drawer.tsx
+++ b/apps/mobile/src/modules/documents/components/import-drawer.tsx
@@ -1,6 +1,7 @@
import type { ThemeColors } from '@/modules/ui/theme.constants';
import { useRouter } from 'expo-router';
import { Modal, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient } from '@/modules/api/providers/api.provider';
import { queryClient } from '@/modules/api/providers/query.provider';
import { useOrganizations } from '@/modules/organizations/organizations.provider';
@@ -16,6 +17,7 @@ type ImportDrawerProps = {
};
export function ImportDrawer({ visible, onClose }: ImportDrawerProps) {
+ const t = useAppTranslations();
const router = useRouter();
const themeColors = useThemeColor();
const { showAlert } = useAlert();
@@ -30,8 +32,8 @@ export function ImportDrawer({ visible, onClose }: ImportDrawerProps) {
try {
if (currentOrganizationId == null) {
showAlert({
- title: 'No Organization Selected',
- message: 'Please select an organization before importing documents.',
+ title: t.documents.import.noOrganization,
+ message: t.documents.import.selectBeforeImport,
});
return;
}
@@ -52,13 +54,13 @@ export function ImportDrawer({ visible, onClose }: ImportDrawerProps) {
});
showAlert({
- title: 'Upload Successful',
- message: `Successfully uploaded: ${localDocument.name}`,
+ title: t.documents.import.uploadSuccessful,
+ message: t.documents.import.uploaded({ name: localDocument.name }),
});
} catch (error) {
showAlert({
- title: 'Error',
- message: error instanceof Error ? error.message : 'Failed to pick document',
+ title: t.common.error,
+ message: error instanceof Error ? error.message : t.documents.import.pickFailed,
});
}
};
@@ -73,7 +75,7 @@ export function ImportDrawer({ visible, onClose }: ImportDrawerProps) {
<TouchableOpacity style={styles.backdrop} activeOpacity={1} onPress={onClose}>
<View style={styles.drawer}>
<View style={styles.header}>
- <Text style={styles.title}>Import Document</Text>
+ <Text style={styles.title}>{t.documents.import.drawerTitle}</Text>
</View>
<View style={styles.optionsContainer}>
@@ -82,8 +84,10 @@ export function ImportDrawer({ visible, onClose }: ImportDrawerProps) {
<Icon name="file-plus" size={24} style={styles.optionIcon} />
</View>
<View style={styles.optionTextContainer}>
- <Text style={styles.optionTitle}>Import from Files</Text>
- <Text style={styles.optionDescription}>Choose a document from your device</Text>
+ <Text style={styles.optionTitle}>{t.documents.import.fromFiles}</Text>
+ <Text style={styles.optionDescription}>
+ {t.documents.import.fromFilesDescription}
+ </Text>
</View>
<Icon name="chevron-right" size={18} style={styles.chevronIcon} />
</TouchableOpacity>
@@ -93,15 +97,15 @@ export function ImportDrawer({ visible, onClose }: ImportDrawerProps) {
<Icon name="camera" size={24} style={styles.optionIcon} />
</View>
<View style={styles.optionTextContainer}>
- <Text style={styles.optionTitle}>Scan Document</Text>
- <Text style={styles.optionDescription}>Use camera to scan a document</Text>
+ <Text style={styles.optionTitle}>{t.documents.import.scan}</Text>
+ <Text style={styles.optionDescription}>{t.documents.import.scanDescription}</Text>
</View>
<Icon name="chevron-right" size={18} style={styles.chevronIcon} />
</TouchableOpacity>
</View>
<TouchableOpacity style={styles.cancelButton} onPress={onClose}>
- <Text style={styles.cancelButtonText}>Cancel</Text>
+ <Text style={styles.cancelButtonText}>{t.common.cancel}</Text>
</TouchableOpacity>
</View>
</TouchableOpacity>
diff --git a/apps/mobile/src/modules/documents/components/rename-document-dialog.tsx b/apps/mobile/src/modules/documents/components/rename-document-dialog.tsx
index 189c1249..f3de361c 100644
--- a/apps/mobile/src/modules/documents/components/rename-document-dialog.tsx
+++ b/apps/mobile/src/modules/documents/components/rename-document-dialog.tsx
@@ -9,6 +9,7 @@ import {
TouchableWithoutFeedback,
View,
} from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useAlert } from '@/modules/ui/providers/alert-provider';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
@@ -25,6 +26,7 @@ export function RenameDocumentDialog({
onConfirm,
onCancel,
}: RenameDocumentDialogProps) {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const { showAlert } = useAlert();
const styles = createStyles({ themeColors });
@@ -47,8 +49,8 @@ export function RenameDocumentDialog({
const handleConfirm = () => {
if (documentName.trim() === '') {
showAlert({
- title: 'Invalid Name',
- message: 'Please enter a document name',
+ title: t.common.invalidName,
+ message: t.documents.nameRequired,
});
return;
}
@@ -75,7 +77,7 @@ export function RenameDocumentDialog({
<TouchableWithoutFeedback>
<View style={styles.content}>
<View style={styles.header}>
- <Text style={styles.title}>Document Name</Text>
+ <Text style={styles.title}>{t.documents.nameTitle}</Text>
</View>
<View style={styles.inputContainer}>
@@ -84,7 +86,7 @@ export function RenameDocumentDialog({
style={styles.input}
value={documentName}
onChangeText={setDocumentName}
- placeholder="Enter document name"
+ placeholder={t.documents.namePlaceholder}
placeholderTextColor={themeColors.mutedForeground}
onSubmitEditing={handleConfirm}
/>
@@ -95,13 +97,13 @@ export function RenameDocumentDialog({
style={[styles.button, styles.cancelButton]}
onPress={handleCancel}
>
- <Text style={styles.cancelButtonText}>Cancel</Text>
+ <Text style={styles.cancelButtonText}>{t.common.cancel}</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.button, styles.confirmButton]}
onPress={handleConfirm}
>
- <Text style={styles.confirmButtonText}>Save</Text>
+ <Text style={styles.confirmButtonText}>{t.common.save}</Text>
</TouchableOpacity>
</View>
</View>
diff --git a/apps/mobile/src/modules/documents/documents-scan/components/document-name-input.tsx b/apps/mobile/src/modules/documents/documents-scan/components/document-name-input.tsx
index fc7c89c0..a8b6fa00 100644
--- a/apps/mobile/src/modules/documents/documents-scan/components/document-name-input.tsx
+++ b/apps/mobile/src/modules/documents/documents-scan/components/document-name-input.tsx
@@ -1,6 +1,7 @@
import type { ScanOutputFormat } from '../documents-scan.types';
import type { ThemeColors } from '@/modules/ui/theme.constants';
import { StyleSheet, Text, TextInput, View } from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
type DocumentNameInputProps = {
@@ -14,18 +15,19 @@ function getFileExtension(format: ScanOutputFormat): string {
}
export function DocumentNameInput({ value, onChangeText, format }: DocumentNameInputProps) {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const styles = createStyles({ themeColors });
return (
<View style={styles.container}>
- <Text style={styles.label}>Document name</Text>
+ <Text style={styles.label}>{t.documents.nameLabel}</Text>
<View style={styles.inputContainer}>
<TextInput
style={styles.input}
value={value}
onChangeText={onChangeText}
- placeholder="Enter document name"
+ placeholder={t.documents.namePlaceholder}
placeholderTextColor={themeColors.mutedForeground}
autoCapitalize="none"
autoCorrect={false}
diff --git a/apps/mobile/src/modules/documents/documents-scan/components/format-selector.tsx b/apps/mobile/src/modules/documents/documents-scan/components/format-selector.tsx
index ae150d20..40d15788 100644
--- a/apps/mobile/src/modules/documents/documents-scan/components/format-selector.tsx
+++ b/apps/mobile/src/modules/documents/documents-scan/components/format-selector.tsx
@@ -2,59 +2,10 @@ import type { ScanOutputFormat } from '../documents-scan.types';
import type { IconName } from '@/modules/ui/components/icon';
import type { ThemeColors } from '@/modules/ui/theme.constants';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { Icon } from '@/modules/ui/components/icon';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
-export const formatOptions: {
- key: ScanOutputFormat;
- icon: IconName;
- singleScan: {
- label: string;
- description: string;
- };
- multiScan: {
- label: string;
- description: string;
- };
-}[] = [
- {
- key: 'pdf-merged',
- icon: 'file-text',
- singleScan: {
- label: 'PDF',
- description: 'Save scan as a PDF',
- },
- multiScan: {
- label: 'PDF',
- description: 'All scans merged into a single multi-page PDF',
- },
- },
- {
- key: 'pdf-per-page',
- icon: 'copy',
- singleScan: {
- label: 'PDF',
- description: 'Save scan as a PDF',
- },
- multiScan: {
- label: 'PDFs',
- description: 'Save each scan as individual PDF',
- },
- },
- {
- key: 'images',
- icon: 'image',
- singleScan: {
- label: 'Image',
- description: 'Save scan as an image',
- },
- multiScan: {
- label: 'Images',
- description: 'Save each scan as individual images',
- },
- },
-];
-
type FormatSelectorProps = {
isSinglePage: boolean;
selectedFormat: ScanOutputFormat;
@@ -66,6 +17,57 @@ export function FormatSelector({
selectedFormat,
onFormatChange,
}: FormatSelectorProps) {
+ const t = useAppTranslations();
+ const formatOptions: {
+ key: ScanOutputFormat;
+ icon: IconName;
+ singleScan: {
+ label: string;
+ description: string;
+ };
+ multiScan: {
+ label: string;
+ description: string;
+ };
+ }[] = [
+ {
+ key: 'pdf-merged',
+ icon: 'file-text',
+ singleScan: {
+ label: t.documents.scan.formats.pdf,
+ description: t.documents.scan.formats.pdfDescription,
+ },
+ multiScan: {
+ label: t.documents.scan.formats.pdf,
+ description: t.documents.scan.formats.mergedDescription,
+ },
+ },
+ {
+ key: 'pdf-per-page',
+ icon: 'copy',
+ singleScan: {
+ label: t.documents.scan.formats.pdf,
+ description: t.documents.scan.formats.pdfDescription,
+ },
+ multiScan: {
+ label: t.documents.scan.formats.pdfs,
+ description: t.documents.scan.formats.pdfsDescription,
+ },
+ },
+ {
+ key: 'images',
+ icon: 'image',
+ singleScan: {
+ label: t.documents.scan.formats.image,
+ description: t.documents.scan.formats.imageDescription,
+ },
+ multiScan: {
+ label: t.documents.scan.formats.images,
+ description: t.documents.scan.formats.imagesDescription,
+ },
+ },
+ ];
+
const themeColors = useThemeColor();
const styles = createStyles({ themeColors });
@@ -82,7 +84,7 @@ export function FormatSelector({
return (
<View style={styles.container}>
- <Text style={styles.label}>Output Format</Text>
+ <Text style={styles.label}>{t.documents.scan.outputFormat}</Text>
<View style={styles.segmentedControl}>
{options.map((option) => (
diff --git a/apps/mobile/src/modules/documents/documents-scan/screens/scan.screen.tsx b/apps/mobile/src/modules/documents/documents-scan/screens/scan.screen.tsx
index 12de3216..7e228481 100644
--- a/apps/mobile/src/modules/documents/documents-scan/screens/scan.screen.tsx
+++ b/apps/mobile/src/modules/documents/documents-scan/screens/scan.screen.tsx
@@ -13,6 +13,7 @@ import {
View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { OrganizationPickerButton } from '@/modules/organizations/components/organization-picker-button';
import { OrganizationPickerDrawer } from '@/modules/organizations/components/organization-picker-drawer';
import { useOrganizations } from '@/modules/organizations/organizations.provider';
@@ -30,6 +31,7 @@ function generateDefaultBaseName({ now = new Date() }: { now?: Date } = {}): str
}
export default function ScanReviewScreen() {
+ const t = useAppTranslations();
const router = useRouter();
const themeColors = useThemeColor();
const styles = createStyles({ themeColors });
@@ -59,8 +61,8 @@ export default function ScanReviewScreen() {
setImageUris(scannedImageUris);
} catch (error) {
showAlert({
- title: 'Scan Error',
- message: error instanceof Error ? error.message : 'Failed to scan document',
+ title: t.documents.scan.errorTitle,
+ message: error instanceof Error ? error.message : t.documents.scan.failed,
});
router.back();
} finally {
@@ -69,7 +71,7 @@ export default function ScanReviewScreen() {
};
void performScan();
- }, [router, showAlert]);
+ }, [router, showAlert, t.documents.scan.errorTitle, t.documents.scan.failed]);
const handleClose = () => {
router.back();
@@ -81,16 +83,16 @@ export default function ScanReviewScreen() {
if (organizationId == null) {
showAlert({
- title: 'No Organization Selected',
- message: 'Please select an organization before uploading.',
+ title: t.documents.import.noOrganization,
+ message: t.documents.scan.selectBeforeUpload,
});
return;
}
if (!baseName) {
showAlert({
- title: 'Name Required',
- message: 'Please enter a document name.',
+ title: t.documents.scan.nameRequiredTitle,
+ message: t.documents.scan.nameRequired,
});
return;
}
@@ -104,17 +106,17 @@ export default function ScanReviewScreen() {
if (result.success) {
showAlert({
- title: 'Upload Successful',
- message: `Successfully uploaded ${result.documentCount} document${result.documentCount > 1 ? 's' : ''}.`,
+ title: t.documents.import.uploadSuccessful,
+ message: t.documents.scan.uploaded({ count: result.documentCount }),
});
router.back();
} else {
showAlert({
- title: 'Upload Failed',
- message: result.error ?? 'Failed to upload documents. Please try again.',
+ title: t.documents.import.uploadFailed,
+ message: result.error ?? t.documents.scan.uploadFailed,
buttons: [
- { text: 'Cancel', style: 'cancel' },
- { text: 'Retry', onPress: () => void handleConfirm() },
+ { text: t.common.cancel, style: 'cancel' },
+ { text: t.common.retry, onPress: () => void handleConfirm() },
],
});
}
@@ -125,7 +127,7 @@ export default function ScanReviewScreen() {
<SafeAreaView style={styles.container}>
<View style={styles.centeredContainer}>
<ActivityIndicator size="large" color={themeColors.primary} />
- <Text style={styles.loadingText}>Opening scanner...</Text>
+ <Text style={styles.loadingText}>{t.documents.scan.opening}</Text>
</View>
</SafeAreaView>
);
@@ -135,9 +137,9 @@ export default function ScanReviewScreen() {
return (
<SafeAreaView style={styles.container}>
<View style={styles.centeredContainer}>
- <Text style={styles.errorText}>No images to review</Text>
+ <Text style={styles.errorText}>{t.documents.scan.empty}</Text>
<TouchableOpacity style={styles.actionButton} onPress={handleClose}>
- <Text style={styles.actionButtonText}>Go Back</Text>
+ <Text style={styles.actionButtonText}>{t.common.goBack}</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
@@ -151,11 +153,8 @@ export default function ScanReviewScreen() {
<TouchableOpacity style={styles.headerButton} onPress={handleClose}>
<Icon name="x" size={24} color={themeColors.foreground} />
</TouchableOpacity>
- <Text style={styles.headerTitle}>Review Scan</Text>
- <Text style={styles.pageCount}>
- {pageCount} page
- {pageCount > 1 ? 's' : ''}
- </Text>
+ <Text style={styles.headerTitle}>{t.documents.scan.title}</Text>
+ <Text style={styles.pageCount}>{t.documents.scan.pageCount({ count: pageCount })}</Text>
</View>
<KeyboardAvoidingView
@@ -179,7 +178,7 @@ export default function ScanReviewScreen() {
<DocumentNameInput value={documentName} onChangeText={setDocumentName} format={format} />
<View style={styles.orgSection}>
- <Text style={styles.sectionLabel}>Upload to</Text>
+ <Text style={styles.sectionLabel}>{t.documents.scan.uploadTo}</Text>
<OrganizationPickerButton onPress={() => setIsOrgPickerVisible(true)} />
</View>
</ScrollView>
@@ -188,7 +187,7 @@ export default function ScanReviewScreen() {
{/* Footer */}
<View style={styles.footer}>
<TouchableOpacity style={styles.cancelButton} onPress={handleClose} disabled={isProcessing}>
- <Text style={styles.cancelButtonText}>Cancel</Text>
+ <Text style={styles.cancelButtonText}>{t.common.cancel}</Text>
</TouchableOpacity>
<TouchableOpacity
@@ -201,7 +200,7 @@ export default function ScanReviewScreen() {
) : (
<>
<Icon name="upload" size={18} color={themeColors.primaryForeground} />
- <Text style={styles.confirmButtonText}>Confirm</Text>
+ <Text style={styles.confirmButtonText}>{t.common.confirm}</Text>
</>
)}
</TouchableOpacity>
@@ -211,7 +210,7 @@ export default function ScanReviewScreen() {
<View style={styles.loadingOverlay}>
<View style={styles.loadingCard}>
<ActivityIndicator size="large" color={themeColors.primary} />
- <Text style={styles.loadingText}>Processing and uploading...</Text>
+ <Text style={styles.loadingText}>{t.documents.scan.processing}</Text>
</View>
</View>
)}
diff --git a/apps/mobile/src/modules/documents/screens/document-details.screen.tsx b/apps/mobile/src/modules/documents/screens/document-details.screen.tsx
index 11656aaa..9ea7df8e 100644
--- a/apps/mobile/src/modules/documents/screens/document-details.screen.tsx
+++ b/apps/mobile/src/modules/documents/screens/document-details.screen.tsx
@@ -17,6 +17,7 @@ import {
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import * as Sharing from 'expo-sharing';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient, useAuthClient } from '@/modules/api/providers/api.provider';
import { DocumentActionSheet } from '@/modules/documents/components/document-action-sheet';
import { fetchDocument, fetchDocumentFile } from '@/modules/documents/documents.services';
@@ -113,6 +114,7 @@ function InfoRow({
}
export function DocumentDetailsScreen() {
+ const t = useAppTranslations();
const router = useRouter();
const params = useLocalSearchParams<{ documentId: string; organizationId: string }>();
const themeColors = useThemeColor();
@@ -133,8 +135,8 @@ export function DocumentDetailsScreen() {
if (organizationId == null || documentId == null) {
showAlert({
- title: 'Error',
- message: 'Organization ID and Document ID are required',
+ title: t.common.error,
+ message: t.documents.missingIds,
});
return null;
}
@@ -184,13 +186,16 @@ export function DocumentDetailsScreen() {
encoding: FileSystem.EncodingType.Base64,
});
- showAlert({ title: 'Downloaded', message: `${document.name} has been saved` });
+ showAlert({
+ title: t.documents.downloaded,
+ message: t.documents.saved({ name: document.name }),
+ });
} else {
// On iOS saving a file goes through the share sheet ("Save to Files")
await Sharing.shareAsync(fileUri);
}
} catch {
- showAlert({ title: 'Error', message: 'Failed to download document file' });
+ showAlert({ title: t.common.error, message: t.documents.downloadFailed });
} finally {
setPendingAction(undefined);
}
@@ -204,8 +209,8 @@ export function DocumentDetailsScreen() {
const canShare = await Sharing.isAvailableAsync();
if (!canShare) {
showAlert({
- title: 'Sharing Failed',
- message: 'Sharing is not available on this device. Please share the document manually.',
+ title: t.documents.sharingFailed,
+ message: t.documents.sharingUnavailable,
});
return;
}
@@ -215,7 +220,7 @@ export function DocumentDetailsScreen() {
const fileUri = await getLocalFileUri();
await Sharing.shareAsync(fileUri);
} catch {
- showAlert({ title: 'Error', message: 'Failed to download document file' });
+ showAlert({ title: t.common.error, message: t.documents.downloadFailed });
} finally {
setPendingAction(undefined);
}
@@ -226,7 +231,7 @@ export function DocumentDetailsScreen() {
return (
<View style={styles.centeredContainer}>
<ActivityIndicator size="large" color={themeColors.primary} />
- <Text style={styles.centeredText}>Loading document...</Text>
+ <Text style={styles.centeredText}>{t.documents.loading}</Text>
</View>
);
}
@@ -235,9 +240,9 @@ export function DocumentDetailsScreen() {
return (
<View style={styles.centeredContainer}>
<Icon name="alert-circle" size={64} color={themeColors.mutedForeground} />
- <Text style={styles.centeredTitle}>Failed to load document</Text>
+ <Text style={styles.centeredTitle}>{t.documents.loadFailed}</Text>
<TouchableOpacity style={styles.retryButton} onPress={() => void documentQuery.refetch()}>
- <Text style={styles.retryButtonText}>Retry</Text>
+ <Text style={styles.retryButtonText}>{t.common.retry}</Text>
</TouchableOpacity>
</View>
);
@@ -269,7 +274,7 @@ export function DocumentDetailsScreen() {
<View style={styles.actionsRow}>
<TouchableOpacity style={styles.openButton} onPress={handleOpen} activeOpacity={0.7}>
<Icon name="eye" size={18} color={themeColors.primaryForeground} />
- <Text style={styles.openButtonText}>Open</Text>
+ <Text style={styles.openButtonText}>{t.common.open}</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.iconButton}
@@ -297,7 +302,7 @@ export function DocumentDetailsScreen() {
{document.tags.length > 0 && (
<View style={styles.section}>
- <Text style={styles.sectionTitle}>Tags</Text>
+ <Text style={styles.sectionTitle}>{t.documents.tags}</Text>
<View style={styles.tagsContainer}>
{document.tags.map((tag) => (
<Tag key={tag.id} name={tag.name} color={tag.color} />
@@ -308,7 +313,7 @@ export function DocumentDetailsScreen() {
{hasNotes && (
<View style={styles.section}>
- <Text style={styles.sectionTitle}>Notes</Text>
+ <Text style={styles.sectionTitle}>{t.documents.notes}</Text>
<View style={styles.card}>
<Text style={styles.notesText} selectable>
{document.notes}
@@ -321,35 +326,35 @@ export function DocumentDetailsScreen() {
<View style={styles.card}>
<InfoRow
icon="file-text"
- label="Name"
+ label={t.common.name}
value={document.name}
styles={styles}
themeColors={themeColors}
/>
<InfoRow
icon="hard-drive"
- label="Size"
+ label={t.documents.size}
value={formatBytes({ bytes: document.originalSize })}
styles={styles}
themeColors={themeColors}
/>
<InfoRow
icon="file"
- label="Type"
+ label={t.documents.type}
value={getDisplayMimeType(document.mimeType)}
styles={styles}
themeColors={themeColors}
/>
<InfoRow
icon="calendar"
- label="Date"
+ label={t.documents.date}
value={formatDate(document.createdAt)}
styles={styles}
themeColors={themeColors}
/>
<InfoRow
icon="hash"
- label="ID"
+ label={t.documents.id}
value={document.id}
isLast
styles={styles}
@@ -360,7 +365,7 @@ export function DocumentDetailsScreen() {
{customProperties.length > 0 && (
<View style={styles.section}>
- <Text style={styles.sectionTitle}>Properties</Text>
+ <Text style={styles.sectionTitle}>{t.documents.properties}</Text>
<View style={styles.card}>
{customProperties.map((property, index) => (
<InfoRow
@@ -387,7 +392,7 @@ export function DocumentDetailsScreen() {
<Icon name="arrow-left" size={22} color={themeColors.foreground} />
</TouchableOpacity>
<Text style={styles.headerTitle} numberOfLines={1}>
- {document?.name ?? 'Document'}
+ {document?.name ?? t.documents.fallbackName}
</Text>
<TouchableOpacity style={styles.headerButton} onPress={() => setIsActionSheetVisible(true)}>
<Icon name="more-vertical" size={22} color={themeColors.foreground} />
diff --git a/apps/mobile/src/modules/documents/screens/document-share.screen.tsx b/apps/mobile/src/modules/documents/screens/document-share.screen.tsx
index 68c87e9b..322ae2be 100644
--- a/apps/mobile/src/modules/documents/screens/document-share.screen.tsx
+++ b/apps/mobile/src/modules/documents/screens/document-share.screen.tsx
@@ -16,6 +16,7 @@ import {
View,
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient } from '@/modules/api/providers/api.provider';
import { queryClient } from '@/modules/api/providers/query.provider';
import { joinFileName, splitFileName } from '@/modules/lib/path/path.models';
@@ -32,6 +33,7 @@ type UploadStatus =
| { state: 'success'; count: number };
export function DocumentShareScreen() {
+ const t = useAppTranslations();
const router = useRouter();
const themeColors = useThemeColor();
const insets = useSafeAreaInsets();
@@ -95,8 +97,8 @@ export function DocumentShareScreen() {
const handleSave = async () => {
if (selectedOrganizationId == null) {
showAlert({
- title: 'No Organization Selected',
- message: 'Please select an organization to save the document to.',
+ title: t.documents.import.noOrganization,
+ message: t.documents.share.selectOrganization,
});
return;
}
@@ -122,8 +124,11 @@ export function DocumentShareScreen() {
setFiles(files.slice(index));
setStatus({ state: 'idle' });
showAlert({
- title: 'Upload Failed',
- message: `Failed to upload ${file.fileName}: ${error instanceof Error ? error.message : 'unknown error'}`,
+ title: t.documents.import.uploadFailed,
+ message: t.documents.share.uploadError({
+ name: file.fileName,
+ error: error instanceof Error ? error.message : t.common.unknownError,
+ }),
});
return;
}
@@ -143,11 +148,11 @@ export function DocumentShareScreen() {
if (status.state === 'success') {
const firstFile = files[0];
- const destinationName = selectedOrganization?.name ?? 'your organization';
+ const destinationName = selectedOrganization?.name ?? t.documents.share.destinationFallback;
const successMessage =
status.count === 1 && firstFile
- ? `${getUploadName(firstFile)} has been saved to ${destinationName}.`
- : `${status.count} documents have been saved to ${destinationName}.`;
+ ? t.documents.share.saved({ name: getUploadName(firstFile), destination: destinationName })
+ : t.documents.share.savedMultiple({ count: status.count, destination: destinationName });
return (
<View style={[styles.container, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
@@ -155,13 +160,13 @@ export function DocumentShareScreen() {
<View style={styles.successIconContainer}>
<Icon name="check" size={40} color={themeColors.primary} />
</View>
- <Text style={styles.successTitle}>Saved to Papra</Text>
+ <Text style={styles.successTitle}>{t.documents.share.savedTitle}</Text>
<Text style={styles.successMessage}>{successMessage}</Text>
<TouchableOpacity
style={[styles.primaryButton, styles.successButton]}
onPress={leaveScreen}
>
- <Text style={styles.primaryButtonText}>Done</Text>
+ <Text style={styles.primaryButtonText}>{t.common.done}</Text>
</TouchableOpacity>
</View>
</View>
@@ -174,7 +179,7 @@ export function DocumentShareScreen() {
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
>
<View style={[styles.header, { paddingTop: insets.top + 12 }]}>
- <Text style={styles.headerTitle}>Save to Papra</Text>
+ <Text style={styles.headerTitle}>{t.documents.share.save}</Text>
<TouchableOpacity
onPress={leaveScreen}
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
@@ -187,7 +192,7 @@ export function DocumentShareScreen() {
<ScrollView style={styles.content} keyboardShouldPersistTaps="handled">
{files.length === 0 ? (
<View style={styles.emptyContainer}>
- <Text style={styles.emptyText}>No shared file to save.</Text>
+ <Text style={styles.emptyText}>{t.documents.share.empty}</Text>
</View>
) : (
<>
@@ -209,13 +214,13 @@ export function DocumentShareScreen() {
{isSingleFile && (
<View style={styles.fieldContainer}>
- <Text style={styles.fieldLabel}>Name</Text>
+ <Text style={styles.fieldLabel}>{t.common.name}</Text>
<View style={styles.nameInputContainer}>
<TextInput
style={styles.nameInput}
value={baseName}
onChangeText={setBaseName}
- placeholder="Document name"
+ placeholder={t.documents.nameLabel}
placeholderTextColor={themeColors.mutedForeground}
editable={status.state !== 'uploading'}
/>
@@ -227,14 +232,14 @@ export function DocumentShareScreen() {
)}
<View style={styles.fieldContainer}>
- <Text style={styles.fieldLabel}>Organization</Text>
+ <Text style={styles.fieldLabel}>{t.organizations.label}</Text>
<TouchableOpacity
style={styles.orgSelector}
onPress={() => setIsOrgPickerVisible(true)}
disabled={status.state === 'uploading'}
>
<Text style={styles.orgSelectorText} numberOfLines={1}>
- {selectedOrganization?.name ?? 'Select an organization'}
+ {selectedOrganization?.name ?? t.organizations.selectPlaceholder}
</Text>
<Icon name="chevron-down" size={20} color={themeColors.mutedForeground} />
</TouchableOpacity>
@@ -256,13 +261,18 @@ export function DocumentShareScreen() {
<ActivityIndicator size="small" color={themeColors.primaryForeground} />
<Text style={styles.primaryButtonText}>
{status.total === 1
- ? 'Uploading…'
- : `Uploading ${status.current} of ${status.total}…`}
+ ? t.documents.share.uploading
+ : t.documents.share.uploadProgress({
+ current: status.current,
+ total: status.total,
+ })}
</Text>
</View>
) : (
<Text style={styles.primaryButtonText}>
- {files.length > 1 ? `Save ${files.length} documents` : 'Save to Papra'}
+ {files.length > 1
+ ? t.documents.share.saveMultiple({ count: files.length })
+ : t.documents.share.save}
</Text>
)}
</TouchableOpacity>
diff --git a/apps/mobile/src/modules/documents/screens/document-view.screen.tsx b/apps/mobile/src/modules/documents/screens/document-view.screen.tsx
index 4636ab60..42d9c2e0 100644
--- a/apps/mobile/src/modules/documents/screens/document-view.screen.tsx
+++ b/apps/mobile/src/modules/documents/screens/document-view.screen.tsx
@@ -17,6 +17,7 @@ import {
} from 'react-native';
import Pdf from 'react-native-pdf';
import { SafeAreaView } from 'react-native-safe-area-context';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient, useAuthClient } from '@/modules/api/providers/api.provider';
import { DocumentActionSheet } from '@/modules/documents/components/document-action-sheet';
import { fetchDocument, fetchDocumentFile } from '@/modules/documents/documents.services';
@@ -53,6 +54,7 @@ function DocumentViewer({
themeColors: ThemeColors;
onError: (message: string) => void;
}) {
+ const t = useAppTranslations();
const { mimeType } = file.doc;
if (mimeType.startsWith('image/')) {
@@ -65,7 +67,7 @@ function DocumentViewer({
source={{ uri: file.uri, cache: true }}
style={styles.documentViewer}
onError={() => {
- onError('Failed to load PDF');
+ onError(t.documents.preview.pdfFailed);
}}
enablePaging
horizontal={false}
@@ -93,8 +95,8 @@ function DocumentViewer({
size={64}
color={themeColors.mutedForeground}
/>
- <Text style={styles.centeredTitle}>Preview not available</Text>
- <Text style={styles.centeredText}>This file type cannot be previewed in the app</Text>
+ <Text style={styles.centeredTitle}>{t.documents.preview.unavailable}</Text>
+ <Text style={styles.centeredText}>{t.documents.preview.unsupported}</Text>
</View>
);
}
@@ -106,10 +108,11 @@ function LoadingState({
styles: ReturnType<typeof createStyles>;
themeColors: ThemeColors;
}) {
+ const t = useAppTranslations();
return (
<View style={styles.centeredContainer}>
<ActivityIndicator size="large" color={themeColors.primary} />
- <Text style={styles.centeredText}>Loading document...</Text>
+ <Text style={styles.centeredText}>{t.documents.loading}</Text>
</View>
);
}
@@ -125,6 +128,7 @@ function ErrorState({
onRetry: () => void;
onGoBack: () => void;
}) {
+ const t = useAppTranslations();
return (
<View style={styles.centeredContainer}>
<MaterialCommunityIcons
@@ -132,18 +136,19 @@ function ErrorState({
size={64}
color={themeColors.mutedForeground}
/>
- <Text style={styles.centeredTitle}>Failed to load document</Text>
+ <Text style={styles.centeredTitle}>{t.documents.loadFailed}</Text>
<TouchableOpacity style={styles.actionButton} onPress={onRetry}>
- <Text style={styles.actionButtonText}>Retry</Text>
+ <Text style={styles.actionButtonText}>{t.common.retry}</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.actionButton} onPress={onGoBack}>
- <Text style={styles.actionButtonText}>Go Back</Text>
+ <Text style={styles.actionButtonText}>{t.common.goBack}</Text>
</TouchableOpacity>
</View>
);
}
export default function DocumentViewScreen() {
+ const t = useAppTranslations();
const router = useRouter();
const params = useLocalSearchParams<{ documentId: string; organizationId: string }>();
const themeColors = useThemeColor();
@@ -157,8 +162,8 @@ export default function DocumentViewScreen() {
if (organizationId == null || documentId == null) {
showAlert({
- title: 'Error',
- message: 'Organization ID and Document ID are required',
+ title: t.common.error,
+ message: t.documents.missingIds,
});
return null;
}
@@ -200,10 +205,10 @@ export default function DocumentViewScreen() {
const isLoading = documentQuery.isLoading || documentFileQuery.isLoading;
const error = documentQuery.error ?? documentFileQuery.error;
const documentFile = documentFileQuery.data;
- const documentName = documentFile?.doc.name ?? 'Document';
+ const documentName = documentFile?.doc.name ?? t.documents.fallbackName;
const handleShowError = (message: string) => {
- showAlert({ title: 'Error', message });
+ showAlert({ title: t.common.error, message });
};
const renderContent = () => {
diff --git a/apps/mobile/src/modules/documents/screens/documents-list.screen.tsx b/apps/mobile/src/modules/documents/screens/documents-list.screen.tsx
index 342953eb..048e996b 100644
--- a/apps/mobile/src/modules/documents/screens/documents-list.screen.tsx
+++ b/apps/mobile/src/modules/documents/screens/documents-list.screen.tsx
@@ -11,6 +11,7 @@ import {
View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient } from '@/modules/api/providers/api.provider';
import { DocumentsList } from '@/modules/documents/components/documents-list';
import { OrganizationPickerButton } from '@/modules/organizations/components/organization-picker-button';
@@ -22,6 +23,7 @@ import { fetchOrganizationDocuments } from '../documents.services';
import { syncUnsyncedDocuments } from '../documents.sync.services';
export function DocumentsListScreen() {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const apiClient = useApiClient();
const { currentOrganizationId, isLoading: isLoadingOrganizations } = useOrganizations();
@@ -70,22 +72,22 @@ export function DocumentsListScreen() {
style={styles.userButton}
onPress={() => router.navigate('/(app)/(with-organizations)/(tabs)/settings')}
accessibilityRole="button"
- accessibilityLabel="User settings"
+ accessibilityLabel={t.documents.userSettings}
>
<Icon name="user" size={20} color={themeColors.foreground} />
</TouchableOpacity>
</View>
- <Text style={styles.title}>Documents</Text>
+ <Text style={styles.title}>{t.documents.title}</Text>
<TouchableOpacity
style={styles.searchButton}
onPress={() => router.navigate('/(app)/(with-organizations)/(tabs)/search')}
accessibilityRole="button"
- accessibilityLabel="Search documents"
+ accessibilityLabel={t.documents.search.placeholder}
>
<Icon name="search" size={18} color={themeColors.mutedForeground} />
- <Text style={styles.searchButtonText}>Search documents</Text>
+ <Text style={styles.searchButtonText}>{t.documents.search.placeholder}</Text>
</TouchableOpacity>
</View>
@@ -97,8 +99,8 @@ export function DocumentsListScreen() {
<DocumentsList
documents={documentsQuery.data?.documents ?? []}
emptyState={{
- title: 'No documents yet',
- subtitle: 'Upload your first document to get started',
+ title: t.documents.emptyTitle,
+ subtitle: t.documents.emptySubtitle,
}}
refreshControl={
<RefreshControl refreshing={documentsQuery.isRefetching} onRefresh={onRefresh} />
diff --git a/apps/mobile/src/modules/documents/screens/documents-search.screen.tsx b/apps/mobile/src/modules/documents/screens/documents-search.screen.tsx
index 03aef000..074cfaca 100644
--- a/apps/mobile/src/modules/documents/screens/documents-search.screen.tsx
+++ b/apps/mobile/src/modules/documents/screens/documents-search.screen.tsx
@@ -12,6 +12,7 @@ import {
View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient } from '@/modules/api/providers/api.provider';
import { DocumentsList } from '@/modules/documents/components/documents-list';
import { useOrganizations } from '@/modules/organizations/organizations.provider';
@@ -23,6 +24,7 @@ const SEARCH_DEBOUNCE_MS = 300;
const pagination = { pageIndex: 0, pageSize: 20 };
export function DocumentsSearchScreen() {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const apiClient = useApiClient();
const { currentOrganizationId } = useOrganizations();
@@ -95,7 +97,7 @@ export function DocumentsSearchScreen() {
<TextInput
ref={searchInputRef}
style={styles.searchInput}
- placeholder="Search documents"
+ placeholder={t.documents.search.placeholder}
placeholderTextColor={themeColors.mutedForeground}
value={searchQuery}
onChangeText={setSearchQuery}
@@ -108,22 +110,22 @@ export function DocumentsSearchScreen() {
onPress={() => setSearchQuery('')}
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
accessibilityRole="button"
- accessibilityLabel="Clear search text"
+ accessibilityLabel={t.documents.search.clear}
>
<Icon name="x" size={18} color={themeColors.mutedForeground} />
</TouchableOpacity>
)}
</View>
<TouchableOpacity onPress={handleCancel} hitSlop={{ top: 10, bottom: 10 }}>
- <Text style={styles.cancelButtonText}>Cancel</Text>
+ <Text style={styles.cancelButtonText}>{t.common.cancel}</Text>
</TouchableOpacity>
</View>
{debouncedSearchQuery === '' ? (
<View style={styles.centerContent}>
<Icon name="search" size={40} color={themeColors.mutedForeground} />
- <Text style={styles.hintText}>Search your documents</Text>
- <Text style={styles.hintSubtext}>Find documents by name or content</Text>
+ <Text style={styles.hintText}>{t.documents.search.hint}</Text>
+ <Text style={styles.hintSubtext}>{t.documents.search.hintDescription}</Text>
</View>
) : searchResultsQuery.isLoading ? (
<View style={styles.centerContent}>
@@ -133,8 +135,8 @@ export function DocumentsSearchScreen() {
<DocumentsList
documents={searchResultsQuery.data?.documents ?? []}
emptyState={{
- title: 'No documents found',
- subtitle: `No results for "${debouncedSearchQuery}"`,
+ title: t.documents.search.empty,
+ subtitle: t.documents.search.noResults({ query: debouncedSearchQuery }),
}}
keyboardShouldPersistTaps="handled"
/>
diff --git a/apps/mobile/src/modules/i18n/translations/en.ts b/apps/mobile/src/modules/i18n/translations/en.ts
index 38906f4e..6e0236d5 100644
--- a/apps/mobile/src/modules/i18n/translations/en.ts
+++ b/apps/mobile/src/modules/i18n/translations/en.ts
@@ -6,6 +6,200 @@ export const en = {
close: 'Close',
cancel: 'Cancel',
ok: 'OK',
+ anErrorOccurred: 'An error occurred',
+ email: 'Email',
+ name: 'Name',
+ error: 'Error',
+ delete: 'Delete',
+ share: 'Share',
+ invalidName: 'Invalid Name',
+ save: 'Save',
+ retry: 'Retry',
+ open: 'Open',
+ goBack: 'Go Back',
+ done: 'Done',
+ confirm: 'Confirm',
+ unknownError: 'unknown error',
+ },
+ navigation: {
+ notFoundTitle: 'Oops!',
+ notFoundMessage: "This screen doesn't exist.",
+ goHome: 'Go to home screen',
+ modalMessage: 'This is a modal',
+ modalTitle: 'Modal',
+ },
+ documents: {
+ title: 'Documents',
+ search: {
+ title: 'Search',
+ placeholder: 'Search documents',
+ clear: 'Clear search text',
+ hint: 'Search your documents',
+ hintDescription: 'Find documents by name or content',
+ empty: 'No documents found',
+ noResults: ({ query }: { query: string }) => `No results for "${query}"`,
+ },
+ import: {
+ title: 'Import',
+ noOrganization: 'No Organization Selected',
+ uploadSuccessful: 'Upload Successful',
+ selectBeforeImport: 'Please select an organization before importing documents.',
+ pickFailed: 'Failed to pick document',
+ drawerTitle: 'Import Document',
+ fromFiles: 'Import from Files',
+ fromFilesDescription: 'Choose a document from your device',
+ scan: 'Scan Document',
+ scanDescription: 'Use camera to scan a document',
+ uploadFailed: 'Upload Failed',
+ uploaded: ({ name }: { name: string }) => `Successfully uploaded: ${name}`,
+ },
+ sharingFailed: 'Sharing Failed',
+ sharingUnavailable:
+ 'Sharing is not available on this device. Please share the document manually.',
+ downloadFailed: 'Failed to download document file',
+ renameFailed: 'Failed to rename document',
+ deleteTitle: 'Delete Document',
+ deleteFailed: 'Failed to delete document',
+ view: 'View document',
+ rename: 'Rename',
+ nameRequired: 'Please enter a document name',
+ nameTitle: 'Document Name',
+ namePlaceholder: 'Enter document name',
+ missingIds: 'Organization ID and Document ID are required',
+ loading: 'Loading document...',
+ loadFailed: 'Failed to load document',
+ fallbackName: 'Document',
+ downloaded: 'Downloaded',
+ tags: 'Tags',
+ notes: 'Notes',
+ size: 'Size',
+ type: 'Type',
+ date: 'Date',
+ id: 'ID',
+ properties: 'Properties',
+ preview: {
+ pdfFailed: 'Failed to load PDF',
+ unavailable: 'Preview not available',
+ unsupported: 'This file type cannot be previewed in the app',
+ },
+ userSettings: 'User settings',
+ emptyTitle: 'No documents yet',
+ emptySubtitle: 'Upload your first document to get started',
+ share: {
+ selectOrganization: 'Please select an organization to save the document to.',
+ destinationFallback: 'your organization',
+ savedTitle: 'Saved to Papra',
+ saved: ({ name, destination }: { name: string; destination: string }) =>
+ `${name} has been saved to ${destination}.`,
+ savedMultiple: ({ count, destination }: { count: number; destination: string }) =>
+ `${count} documents have been saved to ${destination}.`,
+ save: 'Save to Papra',
+ saveMultiple: ({ count }: { count: number }) => `Save ${count} documents`,
+ empty: 'No shared file to save.',
+ uploading: 'Uploading...',
+ uploadError: ({ name, error }: { name: string; error: string }) =>
+ `Failed to upload ${name}: ${error}`,
+ uploadProgress: ({ current, total }: { current: number; total: number }) =>
+ `Uploading ${current} of ${total}...`,
+ },
+ nameLabel: 'Document name',
+ scan: {
+ errorTitle: 'Scan Error',
+ failed: 'Failed to scan document',
+ selectBeforeUpload: 'Please select an organization before uploading.',
+ nameRequiredTitle: 'Name Required',
+ nameRequired: 'Please enter a document name.',
+ uploadFailed: 'Failed to upload documents. Please try again.',
+ uploaded: ({ count }: { count: number }) =>
+ count > 1
+ ? `Successfully uploaded ${count} documents.`
+ : `Successfully uploaded ${count} document.`,
+ pageCount: ({ count }: { count: number }) => (count > 1 ? `${count} pages` : `${count} page`),
+ opening: 'Opening scanner...',
+ empty: 'No images to review',
+ title: 'Review Scan',
+ uploadTo: 'Upload to',
+ processing: 'Processing and uploading...',
+ outputFormat: 'Output Format',
+ formats: {
+ pdf: 'PDF',
+ pdfDescription: 'Save scan as a PDF',
+ mergedDescription: 'All scans merged into a single multi-page PDF',
+ pdfs: 'PDFs',
+ pdfsDescription: 'Save each scan as individual PDF',
+ image: 'Image',
+ imageDescription: 'Save scan as an image',
+ images: 'Images',
+ imagesDescription: 'Save each scan as individual images',
+ },
+ },
+ deleteConfirmation: ({ name }: { name: string }) =>
+ `Are you sure you want to delete "${name}"? It will be moved to the trash.`,
+ saved: ({ name }: { name: string }) => `${name} has been saved`,
+ },
+ auth: {
+ password: 'Password',
+ emailPlaceholder: '[email protected]',
+ validation: {
+ email: 'Please enter a valid email',
+ password: 'Password must be at least 8 characters',
+ name: 'Name is required',
+ },
+ login: {
+ failed: 'Login Failed',
+ socialFailed: 'Sign In Failed',
+ title: 'Welcome Back',
+ subtitle: 'Sign in to your account',
+ passwordPlaceholder: 'Enter your password',
+ submit: 'Sign In',
+ or: 'OR',
+ signupLink: "Don't have an account? Sign up",
+ continueWith: ({ name }: { name: string }) => `Continue with ${name}`,
+ },
+ twoFactor: {
+ title: 'Two-Factor Authentication',
+ subtitle: 'Verify your identity to continue',
+ failed: 'Verification Failed',
+ backupCode: 'Backup code',
+ verificationCode: 'Verification code',
+ backupDescription: 'Enter one of your backup codes',
+ verificationDescription: 'Enter the 6-digit code from your authenticator app',
+ backupPlaceholder: 'Enter a backup code',
+ verificationPlaceholder: '000000',
+ trustDevice: 'Trust this device',
+ verify: 'Verify',
+ useAuthenticator: 'Use an authenticator code',
+ useBackupCode: 'Use a backup code',
+ backToLogin: 'Back to login',
+ },
+ signup: {
+ checkEmail: 'Check your email',
+ verificationSent:
+ 'We sent you a verification link. Please check your email to verify your account.',
+ failed: 'Signup Failed',
+ disabled: 'Registration is currently disabled',
+ backToLogin: 'Go back to login',
+ title: 'Create Account',
+ subtitle: 'Sign up to get started',
+ namePlaceholder: 'Your name',
+ passwordPlaceholder: 'At least 8 characters',
+ submit: 'Sign Up',
+ loginLink: 'Already have an account? Sign in',
+ },
+ },
+ organizations: {
+ label: 'Organization',
+ selectPlaceholder: 'Select an organization',
+ selectTitle: 'Select Organization',
+ createNew: '+ Create New Organization',
+ createFailed: 'Failed to create organization',
+ nameRequired: 'Please enter a valid organization name',
+ createTitle: 'Create organization',
+ createDescription:
+ 'Your documents will be grouped by organization. You can create multiple organizations to separate your documents, for example, for personal and work documents.',
+ nameLabel: 'Organization Name',
+ namePlaceholder: 'My Organization',
+ create: 'Create Organization',
},
appSettings: {
title: 'App settings',
diff --git a/apps/mobile/src/modules/organizations/components/organization-picker-button.tsx b/apps/mobile/src/modules/organizations/components/organization-picker-button.tsx
index 695f0f24..5b4d838e 100644
--- a/apps/mobile/src/modules/organizations/components/organization-picker-button.tsx
+++ b/apps/mobile/src/modules/organizations/components/organization-picker-button.tsx
@@ -1,5 +1,6 @@
import type { ThemeColors } from '@/modules/ui/theme.constants';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { Icon } from '@/modules/ui/components/icon';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
import { useOrganizations } from '../organizations.provider';
@@ -13,13 +14,14 @@ export function OrganizationPickerButton({
onPress,
variant = 'boxed',
}: OrganizationPickerButtonProps) {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const { organizations, currentOrganizationId } = useOrganizations();
const styles = createStyles({ themeColors });
const currentOrganization = organizations.find((org) => org.id === currentOrganizationId);
- const organizationName = currentOrganization?.name ?? 'Select Organization';
+ const organizationName = currentOrganization?.name ?? t.organizations.selectTitle;
if (variant === 'plain') {
return (
diff --git a/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx b/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx
index b83cec2b..519de31c 100644
--- a/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx
+++ b/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx
@@ -9,6 +9,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { Icon } from '@/modules/ui/components/icon';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
import { useOrganizations } from '../organizations.provider';
@@ -28,6 +29,7 @@ export function OrganizationPickerDrawer({
selectedOrganizationId,
onSelectOrganization,
}: OrganizationPickerDrawerProps) {
+ const t = useAppTranslations();
const themeColors = useThemeColor();
const router = useRouter();
const { organizations, currentOrganizationId, setCurrentOrganizationId, isLoading } =
@@ -57,7 +59,7 @@ export function OrganizationPickerDrawer({
<TouchableOpacity style={styles.backdrop} activeOpacity={1} onPress={onClose}>
<View style={styles.drawer}>
<View style={styles.header}>
- <Text style={styles.title}>Select Organization</Text>
+ <Text style={styles.title}>{t.organizations.selectTitle}</Text>
</View>
{isLoading ? (
@@ -96,7 +98,7 @@ export function OrganizationPickerDrawer({
)}
<TouchableOpacity style={styles.createButton} onPress={handleCreateOrganization}>
- <Text style={styles.createButtonText}>+ Create New Organization</Text>
+ <Text style={styles.createButtonText}>{t.organizations.createNew}</Text>
</TouchableOpacity>
</View>
</TouchableOpacity>
diff --git a/apps/mobile/src/modules/organizations/screens/organization-create.screen.tsx b/apps/mobile/src/modules/organizations/screens/organization-create.screen.tsx
index b6a7c396..53b07f42 100644
--- a/apps/mobile/src/modules/organizations/screens/organization-create.screen.tsx
+++ b/apps/mobile/src/modules/organizations/screens/organization-create.screen.tsx
@@ -14,6 +14,7 @@ import {
View,
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useApiClient } from '@/modules/api/providers/api.provider';
import { useAlert } from '@/modules/ui/providers/alert-provider';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
@@ -21,6 +22,7 @@ import { useOrganizations } from '../organizations.provider';
import { createOrganization } from '../organizations.services';
export function OrganizationCreateScreen() {
+ const t = useAppTranslations();
const router = useRouter();
const themeColors = useThemeColor();
const apiClient = useApiClient();
@@ -39,8 +41,8 @@ export function OrganizationCreateScreen() {
},
onError: (error) => {
showAlert({
- title: 'Error',
- message: error instanceof Error ? error.message : 'Failed to create organization',
+ title: t.common.error,
+ message: error instanceof Error ? error.message : t.organizations.createFailed,
});
},
});
@@ -48,8 +50,8 @@ export function OrganizationCreateScreen() {
const handleCreate = () => {
if (organizationName.trim().length === 0) {
showAlert({
- title: 'Invalid Name',
- message: 'Please enter a valid organization name',
+ title: t.common.invalidName,
+ message: t.organizations.nameRequired,
});
return;
}
@@ -66,19 +68,16 @@ export function OrganizationCreateScreen() {
>
<ScrollView contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled">
<View style={styles.header}>
- <Text style={styles.title}>Create organization</Text>
- <Text style={styles.subtitle}>
- Your documents will be grouped by organization. You can create multiple organizations to
- separate your documents, for example, for personal and work documents.
- </Text>
+ <Text style={styles.title}>{t.organizations.createTitle}</Text>
+ <Text style={styles.subtitle}>{t.organizations.createDescription}</Text>
</View>
<View style={styles.formContainer}>
<View style={styles.fieldContainer}>
- <Text style={styles.label}>Organization Name</Text>
+ <Text style={styles.label}>{t.organizations.nameLabel}</Text>
<TextInput
style={styles.input}
- placeholder="My Organization"
+ placeholder={t.organizations.namePlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={organizationName}
onChangeText={setOrganizationName}
@@ -98,7 +97,7 @@ export function OrganizationCreateScreen() {
{createMutation.isPending ? (
<ActivityIndicator color={themeColors.primaryForeground} />
) : (
- <Text style={styles.buttonText}>Create Organization</Text>
+ <Text style={styles.buttonText}>{t.organizations.create}</Text>
)}
</TouchableOpacity>
</View>
diff --git a/apps/mobile/src/modules/ui/providers/alert-provider.tsx b/apps/mobile/src/modules/ui/providers/alert-provider.tsx
index 1ba3acc5..9e7754a8 100644
--- a/apps/mobile/src/modules/ui/providers/alert-provider.tsx
+++ b/apps/mobile/src/modules/ui/providers/alert-provider.tsx
@@ -1,5 +1,6 @@
import type { ReactNode } from 'react';
import { createContext, useContext, useState } from 'react';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { AlertDialog } from '@/modules/ui/components/alert-dialog';
type AlertButton = {
@@ -21,6 +22,7 @@ type AlertContextType = {
const AlertContext = createContext<AlertContextType | null>(null);
export function AlertProvider({ children }: { children: ReactNode }) {
+ const t = useAppTranslations();
const [alertState, setAlertState] = useState<AlertOptions & { visible: boolean }>({
visible: false,
title: '',
@@ -33,7 +35,7 @@ export function AlertProvider({ children }: { children: ReactNode }) {
visible: true,
title: options.title,
message: options.message,
- buttons: options.buttons ?? [{ text: 'OK', style: 'default' }],
+ buttons: options.buttons ?? [{ text: t.common.ok, style: 'default' }],
});
};