Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(mobile): add localization support (#1476)

Corentin Thomasset7b1f20067138
diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts
index 6169803e..0779e90c 100644
--- a/apps/mobile/app.config.ts
+++ b/apps/mobile/app.config.ts
@@ -84,6 +84,7 @@ const config: ExpoConfig = {
androidMultiIntentFilters: ['*/*'],
},
],
+ 'expo-localization',
],
experiments: {
typedRoutes: true,
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
index a05ddda0..5f0aaaad 100644
--- a/apps/mobile/app/_layout.tsx
+++ b/apps/mobile/app/_layout.tsx
@@ -1,5 +1,7 @@
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
import { Stack } from 'expo-router';
+import * as SplashScreen from 'expo-splash-screen';
+import { useEffect } from 'react';
import { ShareIntentProvider } from 'expo-share-intent';
import { StatusBar } from 'expo-status-bar';
import { AppProviders } from '@/modules/app/providers/app-providers';
@@ -7,10 +9,26 @@ import { ShareIntentHandler } from '@/modules/documents/components/share-intent-
import { useColorScheme } from '@/modules/ui/providers/use-color-scheme';
import 'react-native-reanimated';
+import { LocaleProvider } from '@/modules/i18n/hooks/use-locale';
+
+// Splash screen control is best-effort; failures must not block app startup.
+void SplashScreen.preventAutoHideAsync().catch(() => undefined);
export default function RootLayout() {
+ return (
+ <LocaleProvider>
+ <LocalizedLayout />
+ </LocaleProvider>
+ );
+}
+
+function LocalizedLayout() {
const colorScheme = useColorScheme();
+ useEffect(() => {
+ void SplashScreen.hideAsync().catch(() => undefined);
+ }, []);
+
return (
<ShareIntentProvider>
<AppProviders>
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index e7fa3075..05757a39 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -34,6 +34,7 @@
"expo-haptics": "~15.0.8",
"expo-image": "~3.0.11",
"expo-linking": "~8.0.12",
+ "expo-localization": "~17.0.9",
"expo-network": "^8.0.8",
"expo-print": "^15.0.7",
"expo-router": "~6.0.24",
diff --git a/apps/mobile/src/modules/config/screens/server-selection.screen.tsx b/apps/mobile/src/modules/config/screens/server-selection.screen.tsx
index 7f6ad54a..951b52b5 100644
--- a/apps/mobile/src/modules/config/screens/server-selection.screen.tsx
+++ b/apps/mobile/src/modules/config/screens/server-selection.screen.tsx
@@ -16,14 +16,15 @@ import {
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { queryClient } from '@/modules/api/providers/query.provider';
+import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { Icon } from '@/modules/ui/components/icon';
import { useAlert } from '@/modules/ui/providers/alert-provider';
import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
import { MANAGED_SERVER_URL } from '../config.constants';
import { configLocalStorage } from '../config.local-storage';
import { validateCustomHeaders, validateServerUrl } from '../config.models';
-import { pingServer } from '../config.services';
import { configQueryOptions } from '../config.queries';
+import { pingServer } from '../config.services';
function getDefaultCustomServerUrl() {
if (!__DEV__) {
@@ -40,6 +41,7 @@ export function ServerSelectionScreen() {
const { showAlert } = useAlert();
const insets = useSafeAreaInsets();
const styles = createStyles({ themeColors });
+ const t = useAppTranslations();
const [selectedOption, setSelectedOption] = useState<'managed' | 'self-hosted'>('managed');
const [customUrl, setCustomUrl] = useState(getDefaultCustomServerUrl());
@@ -75,9 +77,8 @@ export function ServerSelectionScreen() {
if (urlValidationError) {
showAlert({
- title: 'Invalid URL',
- message:
- 'Please enter a valid server URL. Make sure to include the protocol (http:// or https://).',
+ title: t.serverSelection.errors.invalidUrl.title,
+ message: t.serverSelection.errors.invalidUrl.message,
});
setIsValidating(false);
return;
@@ -89,7 +90,7 @@ export function ServerSelectionScreen() {
if (headersValidationError) {
showAlert({
- title: 'Invalid Custom Header',
+ title: t.serverSelection.errors.invalidCustomHeader.title,
message: headersValidationError.message,
});
setIsValidating(false);
@@ -100,8 +101,8 @@ export function ServerSelectionScreen() {
await pingServer({ url, headers: customHeaders });
} catch {
showAlert({
- title: 'Connection Failed',
- message: 'Could not reach the server.',
+ title: t.serverSelection.errors.connectionFailed.title,
+ message: t.serverSelection.errors.connectionFailed.message,
});
setIsValidating(false);
return;
@@ -120,11 +121,9 @@ export function ServerSelectionScreen() {
router.replace('/auth/login');
} catch (error) {
showAlert({
- title: 'Something Went Wrong',
+ title: t.serverSelection.errors.saveFailed.title,
message:
- error instanceof Error
- ? error.message
- : 'Could not save the server configuration. Please try again.',
+ error instanceof Error ? error.message : t.serverSelection.errors.saveFailed.message,
});
} finally {
setIsValidating(false);
@@ -139,11 +138,11 @@ export function ServerSelectionScreen() {
<ScrollView contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled">
<View style={styles.brandRow}>
<Icon name="file-text" size={28} color={themeColors.primary} />
- <Text style={styles.brandName}>Papra</Text>
+ <Text style={styles.brandName}>{t.papra}</Text>
</View>
- <Text style={styles.title}>Organize, secure &{'\n'}archive your documents.</Text>
- <Text style={styles.subtitle}>First, choose where your documents live.</Text>
+ <Text style={styles.title}>{t.serverSelection.title}</Text>
+ <Text style={styles.subtitle}>{t.serverSelection.subtitle}</Text>
<View style={styles.options}>
<TouchableOpacity
@@ -155,8 +154,10 @@ export function ServerSelectionScreen() {
>
<Icon name="cloud" size={22} color={themeColors.foreground} style={styles.optionIcon} />
<View style={styles.optionContent}>
- <Text style={styles.optionTitle}>Managed Cloud</Text>
- <Text style={styles.optionDescription}>Use the official Papra cloud service</Text>
+ <Text style={styles.optionTitle}>{t.serverSelection.managedCloud.title}</Text>
+ <Text style={styles.optionDescription}>
+ {t.serverSelection.managedCloud.description}
+ </Text>
</View>
</TouchableOpacity>
@@ -174,8 +175,10 @@ export function ServerSelectionScreen() {
style={styles.optionIcon}
/>
<View style={styles.optionContent}>
- <Text style={styles.optionTitle}>Self-Hosted</Text>
- <Text style={styles.optionDescription}>Connect to your own Papra server</Text>
+ <Text style={styles.optionTitle}>{t.serverSelection.selfHosted.title}</Text>
+ <Text style={styles.optionDescription}>
+ {t.serverSelection.selfHosted.description}
+ </Text>
</View>
</TouchableOpacity>
</View>
@@ -183,10 +186,10 @@ export function ServerSelectionScreen() {
<View style={styles.customUrlZone}>
{isSelfHosted && (
<>
- <Text style={styles.inputLabel}>Server URL</Text>
+ <Text style={styles.inputLabel}>{t.serverSelection.serverUrl.label}</Text>
<TextInput
style={styles.input}
- placeholder="https://your-server.com"
+ placeholder={t.serverSelection.serverUrl.placeholder}
placeholderTextColor={themeColors.mutedForeground}
value={customUrl}
onChangeText={setCustomUrl}
@@ -209,8 +212,7 @@ export function ServerSelectionScreen() {
color={themeColors.mutedForeground}
/>
<Text style={styles.customHeadersToggleLabel}>
- Custom headers
- {customHeaderRows.length > 0 ? ` (${customHeaderRows.length})` : ''}
+ {t.serverSelection.customHeaders.label({ count: customHeaderRows.length })}
</Text>
</TouchableOpacity>
@@ -220,7 +222,7 @@ export function ServerSelectionScreen() {
<View key={row.id} style={styles.customHeaderRow}>
<TextInput
style={[styles.input, styles.customHeaderInput]}
- placeholder="Name"
+ placeholder={t.serverSelection.customHeaders.namePlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={row.name}
onChangeText={(name) => updateCustomHeaderRow({ id: row.id, name })}
@@ -234,7 +236,7 @@ export function ServerSelectionScreen() {
styles.customHeaderInput,
styles.customHeaderValueInput,
]}
- placeholder="Value"
+ placeholder={t.serverSelection.customHeaders.valuePlaceholder}
placeholderTextColor={themeColors.mutedForeground}
value={row.value}
onChangeText={(value) => updateCustomHeaderRow({ id: row.id, value })}
@@ -247,7 +249,9 @@ export function ServerSelectionScreen() {
onPress={() => deleteCustomHeaderRow({ id: row.id })}
disabled={isValidating}
accessibilityRole="button"
- accessibilityLabel={`Delete header ${row.name || 'row'}`}
+ accessibilityLabel={t.serverSelection.customHeaders.deleteLabel({
+ name: row.name,
+ })}
>
<Icon name="trash-2" size={18} color={themeColors.mutedForeground} />
</TouchableOpacity>
@@ -261,7 +265,9 @@ export function ServerSelectionScreen() {
accessibilityRole="button"
>
<Icon name="plus" size={16} color={themeColors.foreground} />
- <Text style={styles.addHeaderButtonLabel}>Add header</Text>
+ <Text style={styles.addHeaderButtonLabel}>
+ {t.serverSelection.customHeaders.add}
+ </Text>
</TouchableOpacity>
</View>
)}
@@ -280,7 +286,7 @@ export function ServerSelectionScreen() {
<ActivityIndicator color={themeColors.primaryForeground} />
) : (
<>
- <Text style={styles.buttonText}>Continue</Text>
+ <Text style={styles.buttonText}>{t.serverSelection.continue}</Text>
<Icon name="arrow-right" size={18} color={themeColors.primaryForeground} />
</>
)}
diff --git a/apps/mobile/src/modules/i18n/hooks/use-app-translations.ts b/apps/mobile/src/modules/i18n/hooks/use-app-translations.ts
new file mode 100644
index 00000000..f2bf1cfd
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/hooks/use-app-translations.ts
@@ -0,0 +1,4 @@
+import { locales } from '../locales';
+import { useTranslations } from './use-translations';
+
+export const useAppTranslations = () => useTranslations(locales);
diff --git a/apps/mobile/src/modules/i18n/hooks/use-locale.tsx b/apps/mobile/src/modules/i18n/hooks/use-locale.tsx
new file mode 100644
index 00000000..7588f81c
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/hooks/use-locale.tsx
@@ -0,0 +1,70 @@
+import { createContext, useContext, useEffect, useState } from 'react';
+import type { ReactNode } from 'react';
+import type { LocaleKey } from '../locales';
+import { useLocales } from 'expo-localization';
+import { resolveUserLocale } from '../locales.models';
+import type { LocalePreference } from '../i18n.local-storage';
+import { i18nLocalStorage } from '../i18n.local-storage';
+
+type LocaleProviderContext = {
+ locale: LocaleKey;
+ localePreference: LocalePreference;
+ setLocalePreference: (preference: LocalePreference) => Promise<void>;
+};
+
+const LocaleContext = createContext<LocaleProviderContext | undefined>(undefined);
+
+export function LocaleProvider({ children }: { children: ReactNode }) {
+ const userLocales = useLocales();
+ const [localePreference, setPreference] = useState<LocalePreference>(null);
+ const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);
+
+ useEffect(() => {
+ let cancelled = false;
+
+ void i18nLocalStorage.getLocalePreference().then((preference) => {
+ if (!cancelled) {
+ setPreference(preference);
+ setIsLocaleLoaded(true);
+ }
+ });
+
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+
+ const setLocalePreference = async (preference: LocalePreference) => {
+ // Only update the active preference once it has been saved successfully.
+ await i18nLocalStorage.setLocalePreference(preference);
+ setPreference(preference);
+ };
+
+ const locale = localePreference ?? resolveUserLocale<LocaleKey>(userLocales);
+
+ if (!isLocaleLoaded) {
+ return null;
+ }
+
+ return (
+ <LocaleContext.Provider
+ value={{
+ locale,
+ localePreference,
+ setLocalePreference,
+ }}
+ >
+ {children}
+ </LocaleContext.Provider>
+ );
+}
+
+export function useLocale() {
+ const context = useContext(LocaleContext);
+
+ if (!context) {
+ throw new Error('useLocale must be used within LocaleProvider');
+ }
+
+ return context;
+}
diff --git a/apps/mobile/src/modules/i18n/hooks/use-translations.ts b/apps/mobile/src/modules/i18n/hooks/use-translations.ts
new file mode 100644
index 00000000..f01d72e5
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/hooks/use-translations.ts
@@ -0,0 +1,21 @@
+import { deepMerge } from '@/modules/lib/objects/merge';
+import { useLocale } from './use-locale';
+import { DEFAULT_LOCALE_KEY } from '../locales';
+import type { LocaleRecord } from '../locales';
+import type { PartialMessages } from '../i18n.types';
+
+type GenericMessages = Record<string, unknown>;
+
+export type TranslationMap<TDefault extends GenericMessages> = LocaleRecord<
+ { messages: TDefault },
+ NoInfer<PartialMessages<{ messages: TDefault }>>
+>;
+
+export function useTranslations<TDefault extends GenericMessages>(
+ translations: TranslationMap<TDefault>,
+): TDefault {
+ const { locale } = useLocale();
+ const localeOverrides = translations[locale] ?? {};
+
+ return deepMerge(translations[DEFAULT_LOCALE_KEY].messages, localeOverrides.messages ?? {});
+}
diff --git a/apps/mobile/src/modules/i18n/i18n.local-storage.ts b/apps/mobile/src/modules/i18n/i18n.local-storage.ts
new file mode 100644
index 00000000..59b59050
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/i18n.local-storage.ts
@@ -0,0 +1,30 @@
+import type { LocaleKey } from './locales';
+import { buildStorageKey } from '../lib/local-storage/local-storage.models';
+import { storage } from '../lib/local-storage/local-storage.services';
+import { LOCALE_KEYS } from './locales';
+
+export type LocalePreference = LocaleKey | null;
+
+const LOCALE_PREFERENCE_KEY = buildStorageKey(['i18n', 'locale-preference']);
+
+export const i18nLocalStorage = {
+ getLocalePreference: async (): Promise<LocalePreference> => {
+ try {
+ const storedLocale = await storage.getItem(LOCALE_PREFERENCE_KEY);
+
+ return LOCALE_KEYS.find((key) => key === storedLocale) ?? null;
+ } catch {
+ // Storage failures should not prevent the app from following the device language.
+ return null;
+ }
+ },
+
+ setLocalePreference: async (preference: LocalePreference): Promise<void> => {
+ if (preference === null) {
+ await storage.removeItem(LOCALE_PREFERENCE_KEY);
+ return;
+ }
+
+ await storage.setItem(LOCALE_PREFERENCE_KEY, preference);
+ },
+};
diff --git a/apps/mobile/src/modules/i18n/i18n.types.ts b/apps/mobile/src/modules/i18n/i18n.types.ts
new file mode 100644
index 00000000..3765ba25
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/i18n.types.ts
@@ -0,0 +1,9 @@
+import type { en as enMessages } from './translations/en';
+
+export type AppMessages = typeof enMessages;
+
+export type PartialMessages<T> = T extends (...args: any[]) => any
+ ? T
+ : T extends object
+ ? { [K in keyof T]?: PartialMessages<T[K]> }
+ : T;
diff --git a/apps/mobile/src/modules/i18n/locales.models.test.ts b/apps/mobile/src/modules/i18n/locales.models.test.ts
new file mode 100644
index 00000000..700cf89f
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/locales.models.test.ts
@@ -0,0 +1,79 @@
+import { describe, expect, test } from 'vitest';
+import { resolveUserLocale } from './locales.models';
+
+describe('locales.models', () => {
+ describe('resolveUserLocale', () => {
+ test('when a user locale matches a supported locale key, it returns that key', () => {
+ expect(
+ resolveUserLocale([{ languageTag: 'en' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('en');
+
+ expect(
+ resolveUserLocale([{ languageTag: 'fr' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('fr');
+ });
+
+ test('when a user locale does not match any supported locale key, it returns the default locale key', () => {
+ expect(
+ resolveUserLocale([{ languageTag: 'es' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('en');
+ });
+
+ test('when a user locale matches a supported locale key by language code, it returns that key', () => {
+ expect(
+ resolveUserLocale([{ languageCode: 'en', languageTag: 'en-US' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('en');
+ });
+
+ test('the locale keys are matched case-insensitively', () => {
+ expect(
+ resolveUserLocale([{ languageTag: 'EN' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('en');
+
+ expect(
+ resolveUserLocale([{ languageTag: 'FR' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('fr');
+
+ expect(
+ resolveUserLocale([{ languageCode: 'FR', languageTag: 'fr-FR' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('fr');
+ });
+
+ test('language tag takes precedence over language code when both are present', () => {
+ expect(
+ resolveUserLocale([{ languageCode: 'fr', languageTag: 'en' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('en');
+
+ expect(
+ resolveUserLocale([{ languageCode: 'en', languageTag: 'fr' }], {
+ supportedLocaleKeys: ['en', 'fr'],
+ defaultLocaleKey: 'en',
+ }),
+ ).to.eql('fr');
+ });
+ });
+});
diff --git a/apps/mobile/src/modules/i18n/locales.models.ts b/apps/mobile/src/modules/i18n/locales.models.ts
new file mode 100644
index 00000000..24406b38
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/locales.models.ts
@@ -0,0 +1,30 @@
+import type { LocaleKey } from './locales';
+import { DEFAULT_LOCALE_KEY, LOCALE_KEYS } from './locales';
+
+export function resolveUserLocale<Key extends string = LocaleKey>(
+ userLocales: { languageCode?: string | null; languageTag: string }[],
+ {
+ defaultLocaleKey = DEFAULT_LOCALE_KEY as Key,
+ supportedLocaleKeys = LOCALE_KEYS as Key[],
+ }: { defaultLocaleKey?: Key; supportedLocaleKeys?: Key[] } = {},
+): Key {
+ const localeKeys = new Map(supportedLocaleKeys.map((key) => [key.toLowerCase(), key]));
+
+ for (const userLocale of userLocales) {
+ const languageTag = userLocale.languageTag.toLowerCase();
+
+ const matchedLanguageTag = localeKeys.get(languageTag);
+ if (matchedLanguageTag) {
+ return matchedLanguageTag;
+ }
+
+ const languageCode = userLocale.languageCode?.toLowerCase();
+
+ const matchedLanguageCode = languageCode && localeKeys.get(languageCode);
+ if (matchedLanguageCode) {
+ return matchedLanguageCode;
+ }
+ }
+
+ return defaultLocaleKey;
+}
diff --git a/apps/mobile/src/modules/i18n/locales.ts b/apps/mobile/src/modules/i18n/locales.ts
new file mode 100644
index 00000000..3ddd71b1
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/locales.ts
@@ -0,0 +1,30 @@
+import type { PartialMessages } from './i18n.types';
+import { en } from './translations/en';
+import { fr } from './translations/fr';
+
+export const locales = {
+ en: {
+ name: 'English',
+ messages: en,
+ },
+ fr: {
+ name: 'Français',
+ messages: fr,
+ },
+};
+
+export type LocaleKey = keyof typeof locales;
+
+export const LOCALE_KEYS: LocaleKey[] = Object.keys(locales) as LocaleKey[];
+export const DEFAULT_LOCALE_KEY = 'en';
+
+export type DefaultLocaleKey = typeof DEFAULT_LOCALE_KEY;
+export type NonDefaultLocaleKey = Exclude<LocaleKey, DefaultLocaleKey>;
+
+// Partial but the default locale is required
+export type LocaleRecord<Default, NonDefault = Default> = Partial<
+ Record<NonDefaultLocaleKey, NonDefault>
+> &
+ Record<DefaultLocaleKey, Default>;
+
+export type LocaleTranslationsRecord<T> = LocaleRecord<T, PartialMessages<T>>;
diff --git a/apps/mobile/src/modules/i18n/translations/en.ts b/apps/mobile/src/modules/i18n/translations/en.ts
new file mode 100644
index 00000000..8b1f3b1d
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/translations/en.ts
@@ -0,0 +1,46 @@
+export const en = {
+ papra: 'Papra',
+ serverSelection: {
+ title: 'Organize, secure &\narchive your documents.',
+ subtitle: 'First, choose where your documents live.',
+ continue: 'Continue',
+ managedCloud: {
+ title: 'Managed Cloud',
+ description: 'Use the official Papra cloud service',
+ },
+ selfHosted: {
+ title: 'Self-Hosted',
+ description: 'Connect to your own Papra server',
+ },
+ serverUrl: {
+ label: 'Server URL',
+ placeholder: 'https://your-server.com',
+ },
+ customHeaders: {
+ label: ({ count }: { count: number }) =>
+ count > 0 ? `Custom headers (${count})` : 'Custom headers',
+ namePlaceholder: 'Name',
+ valuePlaceholder: 'Value',
+ deleteLabel: ({ name }: { name: string }) => `Delete header ${name}`,
+ add: 'Add header',
+ },
+ errors: {
+ invalidUrl: {
+ title: 'Invalid URL',
+ message:
+ 'Please enter a valid server URL. Make sure to include the protocol (http:// or https://).',
+ },
+ invalidCustomHeader: {
+ title: 'Invalid Custom Header',
+ },
+ connectionFailed: {
+ title: 'Connection Failed',
+ message: 'Could not reach the server.',
+ },
+ saveFailed: {
+ title: 'Something Went Wrong',
+ message: 'Could not save the server configuration. Please try again.',
+ },
+ },
+ },
+};
diff --git a/apps/mobile/src/modules/i18n/translations/fr.ts b/apps/mobile/src/modules/i18n/translations/fr.ts
new file mode 100644
index 00000000..0bbab63d
--- /dev/null
+++ b/apps/mobile/src/modules/i18n/translations/fr.ts
@@ -0,0 +1,8 @@
+import type { AppMessages, PartialMessages } from '../i18n.types';
+
+export const fr = {
+ serverSelection: {
+ title: 'Organisez, sécurisez &\narchivez vos documents.',
+ subtitle: 'Tout d’abord, choisissez où vos documents se trouvent.',
+ },
+} satisfies PartialMessages<AppMessages>;
diff --git a/apps/mobile/src/modules/lib/objects/merge.ts b/apps/mobile/src/modules/lib/objects/merge.ts
new file mode 100644
index 00000000..f3a71bf8
--- /dev/null
+++ b/apps/mobile/src/modules/lib/objects/merge.ts
@@ -0,0 +1,27 @@
+export function isObject(value: unknown): value is Record<string, unknown> {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
+
+export function deepMerge<T extends Record<string, unknown>>(
+ target: T,
+ source: Record<string, unknown>,
+): T {
+ const result: Record<string, unknown> = { ...target };
+
+ for (const key in source) {
+ if (source[key] === undefined) {
+ continue;
+ }
+
+ if (isObject(source[key]) && isObject(result[key])) {
+ result[key] = deepMerge(
+ result[key] as Record<string, unknown>,
+ source[key] as Record<string, unknown>,
+ );
+ } else {
+ result[key] = source[key];
+ }
+ }
+
+ return result as T;
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9305d1ed..17a5ab46 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -214,6 +214,9 @@ importers:
expo-linking:
specifier: ~8.0.12
+ expo-localization:
+ specifier: ~17.0.9
expo-network:
specifier: ^8.0.8
@@ -6698,6 +6701,12 @@ packages:
react: '*'
react-native: '*'
+ resolution: {integrity: sha512-k5eYHr7iLMob3M8cHH6bgDrDRmqnZG8xKGLhpx8ST+LsFXmSgYpJ/t0VwWm0gz64C/K669XhObdG3D6QwCGqhw==}
+ peerDependencies:
+ expo: '*'
+ react: '*'
+
resolution: {integrity: sha512-WOaud6UKg16ciCOj8raKcMOoKFMHLXKI29U29yhgu1lf+Y7VxJyCktUcYo6AM+ccZ7zLD1uWZdMtgnpf+95OXA==}
hasBin: true
@@ -9229,6 +9238,9 @@ packages:
resolution: {integrity: sha512-sz2eb4tcCFtwVfs5Ei/l3JnSQGqpDv+drFuNz/zwn2tA24cL2WTuk2VMo2bA4IcRgkn38juAOri2hB9nv85u2Q==}
+ resolution: {integrity: sha512-PGMBq03+TTG/p/cRB7HCLKJ1MgDIi07+QU1faSjiYRfmY5UsAttV9Hs08jDAHVwcOwmVLcSJkpwyfXszVjWfIQ==}
+
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
@@ -18967,6 +18979,12 @@ snapshots:
- expo
- supports-color
+ dependencies:
+ react: 19.1.0
+ rtl-detect: 1.1.2
+
dependencies:
'@expo/spawn-async': 1.8.0
@@ -22664,6 +22682,8 @@ snapshots:
iconv-lite: 0.4.24
readable-stream: 2.3.8
+
dependencies:
queue-microtask: 1.2.3