Complete client UI i18n migration
Adds client-side i18n support, language settings, translated UI copy, and locale parity coverage.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useRef } from "react";
|
||||
import { Alert } from "react-native";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getDesktopHost, isElectronRuntime } from "@/desktop/host";
|
||||
import {
|
||||
normalizePickedImageAssets,
|
||||
@@ -14,6 +15,7 @@ interface UseImageAttachmentPickerResult {
|
||||
}
|
||||
|
||||
export function useImageAttachmentPicker(): UseImageAttachmentPickerResult {
|
||||
const { t } = useTranslation();
|
||||
const [mediaPermission, requestMediaPermission] = ImagePicker.useMediaLibraryPermissions();
|
||||
const isPickingRef = useRef(false);
|
||||
|
||||
@@ -31,14 +33,14 @@ export function useImageAttachmentPicker(): UseImageAttachmentPickerResult {
|
||||
|
||||
if (!currentPermission?.granted) {
|
||||
Alert.alert(
|
||||
"Permission required",
|
||||
"Please allow access to your photo library to attach images.",
|
||||
t("imageAttachmentPicker.permissionTitle"),
|
||||
t("imageAttachmentPicker.permissionMessage"),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, [mediaPermission, requestMediaPermission]);
|
||||
}, [mediaPermission, requestMediaPermission, t]);
|
||||
|
||||
const pickImages = useCallback(async () => {
|
||||
if (isPickingRef.current) {
|
||||
@@ -83,12 +85,12 @@ export function useImageAttachmentPicker(): UseImageAttachmentPickerResult {
|
||||
return await normalizePickedImageAssets(result.assets);
|
||||
} catch (error) {
|
||||
console.error("[ImageAttachmentPicker] Failed to pick image:", error);
|
||||
Alert.alert("Error", "Failed to select image");
|
||||
Alert.alert(t("imageAttachmentPicker.errorTitle"), t("imageAttachmentPicker.failedToSelect"));
|
||||
return null;
|
||||
} finally {
|
||||
isPickingRef.current = false;
|
||||
}
|
||||
}, [ensurePermission]);
|
||||
}, [ensurePermission, t]);
|
||||
|
||||
return { pickImages };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user