Internationalize Bible UI and add locale-aware translation fetch

This commit is contained in:
Adolfo Reyna
2026-02-24 16:04:32 -05:00
parent ccfeed3c92
commit fc3159d3fb
6 changed files with 136 additions and 34 deletions

View File

@@ -3,6 +3,7 @@ import { StyleSheet, Text, View } from "react-native";
import { ActivityIndicator, Chip } from "react-native-paper";
import { useNavigation } from "@react-navigation/native";
import { extractBibleReferences, fetchBiblePassage } from "../utils/bibleReferences.js";
import i18n from "../i18nMessages.js";
const BibleEmbeddedView = ({ content = "", compact = false, openChapterOnPress = false }) => {
const navigation = useNavigation();
@@ -23,7 +24,7 @@ const BibleEmbeddedView = ({ content = "", compact = false, openChapterOnPress =
setByReference((prev) => ({ ...prev, [reference]: { loading: true } }));
try {
const data = await fetchBiblePassage(reference);
const data = await fetchBiblePassage(reference, i18n.locale);
setByReference((prev) => ({ ...prev, [reference]: { loading: false, ...data } }));
} catch (_error) {
setByReference((prev) => ({ ...prev, [reference]: { loading: false, error: true } }));
@@ -34,7 +35,7 @@ const BibleEmbeddedView = ({ content = "", compact = false, openChapterOnPress =
return (
<View style={[styles.container, compact ? styles.compactContainer : null]}>
<Text style={styles.label}>Bible</Text>
<Text style={styles.label}>{i18n.t("message.bible")}</Text>
<View style={styles.chipsWrap}>
{references.map((reference) => (
<Chip
@@ -58,7 +59,7 @@ const BibleEmbeddedView = ({ content = "", compact = false, openChapterOnPress =
</Text>
</View>
) : null}
{selectedData?.error ? <Text style={styles.errorText}>Unable to load this passage.</Text> : null}
{selectedData?.error ? <Text style={styles.errorText}>{i18n.t("message.unableLoadPassage")}</Text> : null}
</View>
);
};