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,8 +3,9 @@ import { FlatList, Pressable, View } from "react-native";
import { ActivityIndicator, Text } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import { useNavigation } from "@react-navigation/native";
import { parseBibleReference } from "../utils/bibleReferences.js";
import { fetchBibleChapter, parseBibleReference } from "../utils/bibleReferences.js";
import GlobalState from "../contexts/GlobalState.js";
import i18n from "../i18nMessages.js";
const BibleChapterView = ({ route }) => {
const navigation = useNavigation();
@@ -23,14 +24,12 @@ const BibleChapterView = ({ route }) => {
setLoading(true);
setError("");
try {
const response = await fetch(`https://bible-api.com/${encodeURIComponent(chapterReference)}`);
if (!response.ok) throw new Error("Failed chapter request");
const payload = await response.json();
const payload = await fetchBibleChapter(chapterReference, i18n.locale);
if (!mounted) return;
setChapterData(payload);
} catch (_error) {
if (!mounted) return;
setError("Unable to load chapter.");
setError(i18n.t("message.unableLoadChapter"));
setChapterData(null);
} finally {
if (mounted) setLoading(false);
@@ -100,7 +99,7 @@ const BibleChapterView = ({ route }) => {
{chapterData?.translation_name || chapterData?.translation_id || "KJV"}
</Text>
{selectable ? (
<Text style={{ color: "#6b7280", marginBottom: 8 }}>Tap a verse to select it.</Text>
<Text style={{ color: "#6b7280", marginBottom: 8 }}>{i18n.t("message.tapVerseToSelect")}</Text>
) : null}
<FlatList
ref={listRef}