diff --git a/boilerplate/app/app.tsx b/boilerplate/app/app.tsx index 67873286b..dd7b7f2d1 100644 --- a/boilerplate/app/app.tsx +++ b/boilerplate/app/app.tsx @@ -17,9 +17,10 @@ if (__DEV__) { require("./devtools/ReactotronConfig.ts") } import "./utils/gestureHandler" -import "./i18n" +import { initI18n } from "./i18n" import "./utils/ignoreWarnings" import { useFonts } from "expo-font" +import { useEffect, useState } from "react" import { initialWindowMetrics, SafeAreaProvider } from "react-native-safe-area-context" import * as Linking from "expo-linking" import { useInitialRootStore } from "./models" // @mst remove-current-line @@ -71,6 +72,11 @@ function App(props: AppProps) { } = useNavigationPersistence(storage, NAVIGATION_PERSISTENCE_KEY) const [areFontsLoaded, fontLoadError] = useFonts(customFontsToLoad) + const [isI18nInitialized, setIsI18nInitialized] = useState(false) + + useEffect(() => { + initI18n().then(() => setIsI18nInitialized(true)) + }, []) // @mst replace-next-line React.useEffect(() => { const { rehydrated } = useInitialRootStore(() => { @@ -93,7 +99,12 @@ function App(props: AppProps) { // In Android: https://stackoverflow.com/a/45838109/204044 // You can replace with your own loading component if you wish. // @mst replace-next-line if (!isNavigationStateRestored || (!areFontsLoaded && !fontLoadError)) { - if (!rehydrated || !isNavigationStateRestored || (!areFontsLoaded && !fontLoadError)) { + if ( + !rehydrated || + !isNavigationStateRestored || + !isI18nInitialized || + (!areFontsLoaded && !fontLoadError) + ) { return null } diff --git a/boilerplate/app/components/Button.tsx b/boilerplate/app/components/Button.tsx index 8befa0fc5..2c97647f2 100644 --- a/boilerplate/app/components/Button.tsx +++ b/boilerplate/app/components/Button.tsx @@ -91,7 +91,7 @@ export interface ButtonProps extends PressableProps { * @returns {JSX.Element} The rendered `Button` component. * @example * diff --git a/boilerplate/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx b/boilerplate/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx index 1b6e4787f..448f608d1 100644 --- a/boilerplate/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx +++ b/boilerplate/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx @@ -213,7 +213,7 @@ export const DemoShowroomScreen: FC> = renderSectionFooter={() => } ListHeaderComponent={ - + } onScrollToIndexFailed={scrollToIndexFailed} diff --git a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoAutoImage.tsx b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoAutoImage.tsx index a72923f27..f16a4ba4c 100644 --- a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoAutoImage.tsx +++ b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoAutoImage.tsx @@ -37,9 +37,9 @@ const $aspectRatioBox: ThemedStyle = (theme) => ({ export const DemoAutoImage: Demo = { name: "AutoImage", - description: "demoAutoImage.description", + description: "demoAutoImage:description", data: ({ theme, themed }) => [ - + , - + , - {translate("demoAutoImage.useCase.scaledToFitDimensions.heightAuto")} + {translate("demoAutoImage:useCase.scaledToFitDimensions.heightAuto")} @@ -162,7 +162,7 @@ export const DemoAutoImage: Demo = { - {translate("demoAutoImage.useCase.scaledToFitDimensions.widthAuto")} + {translate("demoAutoImage:useCase.scaledToFitDimensions.widthAuto")} @@ -218,7 +218,7 @@ export const DemoAutoImage: Demo = { - {translate("demoAutoImage.useCase.scaledToFitDimensions.bothManual")} + {translate("demoAutoImage:useCase.scaledToFitDimensions.bothManual")} , ], diff --git a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoButton.tsx b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoButton.tsx index e02680d63..3ed7715d0 100644 --- a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoButton.tsx +++ b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoButton.tsx @@ -44,11 +44,11 @@ const $disabledButtonTextStyle: ThemedStyle = ({ colors }) => ({ export const DemoButton: Demo = { name: "Button", - description: "demoButton.description", + description: "demoButton:description", data: ({ themed }) => [ @@ -60,16 +60,16 @@ export const DemoButton: Demo = { , - + @@ -88,20 +88,20 @@ export const DemoButton: Demo = { )} > - {translate("demoButton.useCase.passingContent.leftAccessory")} + {translate("demoButton:useCase.passingContent.leftAccessory")} @@ -116,21 +116,21 @@ export const DemoButton: Demo = { )} > - {translate("demoButton.useCase.passingContent.multiLine")} + {translate("demoButton:useCase.passingContent.multiLine")} , @@ -138,7 +138,7 @@ export const DemoButton: Demo = { preset="reversed" RightAccessory={() => } > - {translate("demoButton.useCase.styling.styleAccessories")} + {translate("demoButton:useCase.styling.styleAccessories")} @@ -156,13 +156,13 @@ export const DemoButton: Demo = { /> )} > - {translate("demoButton.useCase.styling.pressedState")} + {translate("demoButton:useCase.styling.pressedState")} , @@ -181,7 +181,7 @@ export const DemoButton: Demo = { pressedStyle={themed($customButtonPressedStyle)} pressedTextStyle={themed($customButtonPressedTextStyle)} > - {translate("demoButton.useCase.disabling.filled")} + {translate("demoButton:useCase.disabling.filled")} @@ -192,7 +192,7 @@ export const DemoButton: Demo = { pressedStyle={themed($customButtonPressedStyle)} pressedTextStyle={themed($customButtonPressedTextStyle)} > - {translate("demoButton.useCase.disabling.reversed")} + {translate("demoButton:useCase.disabling.reversed")} @@ -210,7 +210,7 @@ export const DemoButton: Demo = { /> )} > - {translate("demoButton.useCase.disabling.accessory")} + {translate("demoButton:useCase.disabling.accessory")} @@ -221,7 +221,7 @@ export const DemoButton: Demo = { pressedStyle={themed($customButtonPressedStyle)} pressedTextStyle={themed($customButtonPressedTextStyle)} > - {translate("demoButton.useCase.disabling.textStyle")} + {translate("demoButton:useCase.disabling.textStyle")} , ], diff --git a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoCard.tsx b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoCard.tsx index 8c9f574b3..e5660e3ff 100644 --- a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoCard.tsx +++ b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoCard.tsx @@ -6,88 +6,88 @@ import { DemoUseCase } from "../DemoUseCase" export const DemoCard: Demo = { name: "Card", - description: "demoCard.description", + description: "demoCard:description", data: ({ theme }) => [ , , , , [ , , = ({ colors }) => ({ export const DemoHeader: Demo = { name: "Header", - description: "demoHeader.description", + description: "demoHeader:description", data: ({ theme, themed }) => [
,
,
,
,
= ({ colors }) => ({ export const DemoIcon: Demo = { name: "Icon", - description: "demoIcon.description", + description: "demoIcon:description", data: ({ theme, themed }) => [ @@ -52,8 +52,8 @@ export const DemoIcon: Demo = { , @@ -63,8 +63,8 @@ export const DemoIcon: Demo = { , , = ({ colors, spacing }) => ({ export const DemoListItem: Demo = { name: "ListItem", - description: "demoListItem.description", + description: "demoListItem:description", data: ({ theme, themed }) => [ - {translate("demoListItem.useCase.height.defaultHeight")} + {translate("demoListItem:useCase.height.defaultHeight")} - {translate("demoListItem.useCase.height.customHeight")} + {translate("demoListItem:useCase.height.customHeight")} - {translate("demoListItem.useCase.height.textHeight")} + {translate("demoListItem:useCase.height.textHeight")} - {translate("demoListItem.useCase.height.longText")} + {translate("demoListItem:useCase.height.longText")} , - {translate("demoListItem.useCase.separators.topSeparator")} + {translate("demoListItem:useCase.separators.topSeparator")} - {translate("demoListItem.useCase.separators.topAndBottomSeparator")} + {translate("demoListItem:useCase.separators.topAndBottomSeparator")} - {translate("demoListItem.useCase.separators.bottomSeparator")} + {translate("demoListItem:useCase.separators.bottomSeparator")} , - {translate("demoListItem.useCase.icons.leftIcon")} + {translate("demoListItem:useCase.icons.leftIcon")} - {translate("demoListItem.useCase.icons.rightIcon")} + {translate("demoListItem:useCase.icons.rightIcon")} - {translate("demoListItem.useCase.icons.leftRightIcons")} + {translate("demoListItem:useCase.icons.leftRightIcons")} , } > - {translate("demoListItem.useCase.customLeftRight.customLeft")} + {translate("demoListItem:useCase.customLeftRight.customLeft")} } > - {translate("demoListItem.useCase.customLeftRight.customRight")} + {translate("demoListItem:useCase.customLeftRight.customRight")} , - - - {translate("demoListItem.useCase.passingContent.children")} + + + {translate("demoListItem:useCase.passingContent.children")} - {translate("demoListItem.useCase.passingContent.nestedChildren1")} + {translate("demoListItem:useCase.passingContent.nestedChildren1")} {` `} - {translate("demoListItem.useCase.passingContent.nestedChildren2")} + {translate("demoListItem:useCase.passingContent.nestedChildren2")} , @@ -171,11 +171,11 @@ export const DemoListItem: Demo = { , - {translate("demoListItem.useCase.styling.styledText")} + {translate("demoListItem:useCase.styling.styledText")} - {translate("demoListItem.useCase.styling.styledText")} + {translate("demoListItem:useCase.styling.styledText")} - {translate("demoListItem.useCase.styling.styledContainer")} + {translate("demoListItem:useCase.styling.styledContainer")} - {translate("demoListItem.useCase.styling.tintedIcons")} + {translate("demoListItem:useCase.styling.tintedIcons")} , ], diff --git a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoText.tsx b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoText.tsx index be65e15f9..12be402be 100644 --- a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoText.tsx +++ b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoText.tsx @@ -7,113 +7,113 @@ import { translate } from "@/i18n" export const DemoText: Demo = { name: "Text", - description: "demoText.description", + description: "demoText:description", data: ({ theme }) => [ - {translate("demoText.useCase.presets.default")} + {translate("demoText:useCase.presets.default")} - {translate("demoText.useCase.presets.bold")} + {translate("demoText:useCase.presets.bold")} - {translate("demoText.useCase.presets.subheading")} + {translate("demoText:useCase.presets.subheading")} - {translate("demoText.useCase.presets.heading")} + {translate("demoText:useCase.presets.heading")} , - {translate("demoText.useCase.sizes.xs")} + {translate("demoText:useCase.sizes.xs")} - {translate("demoText.useCase.sizes.sm")} + {translate("demoText:useCase.sizes.sm")} - {translate("demoText.useCase.sizes.md")} + {translate("demoText:useCase.sizes.md")} - {translate("demoText.useCase.sizes.lg")} + {translate("demoText:useCase.sizes.lg")} - {translate("demoText.useCase.sizes.xl")} + {translate("demoText:useCase.sizes.xl")} - {translate("demoText.useCase.sizes.xxl")} + {translate("demoText:useCase.sizes.xxl")} , - {translate("demoText.useCase.weights.light")} + {translate("demoText:useCase.weights.light")} - {translate("demoText.useCase.weights.normal")} + {translate("demoText:useCase.weights.normal")} - {translate("demoText.useCase.weights.medium")} + {translate("demoText:useCase.weights.medium")} - {translate("demoText.useCase.weights.semibold")} + {translate("demoText:useCase.weights.semibold")} - {translate("demoText.useCase.weights.bold")} + {translate("demoText:useCase.weights.bold")} , - + - - + + - {translate("demoText.useCase.passingContent.children")} + {translate("demoText:useCase.passingContent.children")} - {translate("demoText.useCase.passingContent.nestedChildren")} - {translate("demoText.useCase.passingContent.nestedChildren2")} + {translate("demoText:useCase.passingContent.nestedChildren")} + {translate("demoText:useCase.passingContent.nestedChildren2")} {` `} - {translate("demoText.useCase.passingContent.nestedChildren3")} + {translate("demoText:useCase.passingContent.nestedChildren3")} {` `} - {translate("demoText.useCase.passingContent.nestedChildren4")} + {translate("demoText:useCase.passingContent.nestedChildren4")} , - {translate("demoText.useCase.styling.text")} + {translate("demoText:useCase.styling.text")} {` `} - {translate("demoText.useCase.styling.text2")} + {translate("demoText:useCase.styling.text2")} {` `} - {translate("demoText.useCase.styling.text3")} + {translate("demoText:useCase.styling.text3")} , diff --git a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoTextField.tsx b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoTextField.tsx index 8eb192e93..a396f4dd4 100644 --- a/boilerplate/app/screens/DemoShowroomScreen/demos/DemoTextField.tsx +++ b/boilerplate/app/screens/DemoShowroomScreen/demos/DemoTextField.tsx @@ -42,19 +42,19 @@ const $customRightAccessoryStyle: ThemedStyle = ({ colors }) => ({ export const DemoTextField: Demo = { name: "TextField", - description: "demoTextField.description", + description: "demoTextField:description", data: ({ themed }) => [ @@ -63,11 +63,11 @@ export const DemoTextField: Demo = { @@ -76,36 +76,36 @@ export const DemoTextField: Demo = { , @@ -113,9 +113,9 @@ export const DemoTextField: Demo = { } /> @@ -123,9 +123,9 @@ export const DemoTextField: Demo = { } @@ -134,9 +134,9 @@ export const DemoTextField: Demo = { , = ({ spacing }) => ({ export const DemoToggle: Demo = { name: "Toggle", - description: "demoToggle.description", + description: "demoToggle:description", data: ({ theme, themed }) => [ , @@ -79,7 +79,7 @@ export const DemoToggle: Demo = { - {translate("demoToggle.useCase.statuses.noStatus")} + {translate("demoToggle:useCase.statuses.noStatus")} @@ -92,7 +92,7 @@ export const DemoToggle: Demo = { - {translate("demoToggle.useCase.statuses.errorStatus")} + {translate("demoToggle:useCase.statuses.errorStatus")} @@ -105,37 +105,37 @@ export const DemoToggle: Demo = { - {translate("demoToggle.useCase.statuses.disabledStatus")} + {translate("demoToggle:useCase.statuses.disabledStatus")} , @@ -143,28 +143,28 @@ export const DemoToggle: Demo = { value status="error" icon="ladybug" - labelTx="demoToggle.useCase.passingContent.useCase.customCheckBox.label" + labelTx="demoToggle:useCase.passingContent.useCase.customCheckBox.label" /> , - {translate("demoToggle.useCase.styling.outerWrapper")} + {translate("demoToggle:useCase.styling.outerWrapper")} @@ -246,7 +246,7 @@ export const DemoToggle: Demo = { }} /> - {translate("demoToggle.useCase.styling.innerWrapper")} + {translate("demoToggle:useCase.styling.innerWrapper")} @@ -316,7 +316,7 @@ export const DemoToggle: Demo = { /> - {translate("demoToggle.useCase.styling.inputDetail")} + {translate("demoToggle:useCase.styling.inputDetail")} @@ -324,7 +324,7 @@ export const DemoToggle: Demo = { diff --git a/boilerplate/app/screens/ErrorScreen/ErrorDetails.tsx b/boilerplate/app/screens/ErrorScreen/ErrorDetails.tsx index 8a45dfd11..85fe45a89 100644 --- a/boilerplate/app/screens/ErrorScreen/ErrorDetails.tsx +++ b/boilerplate/app/screens/ErrorScreen/ErrorDetails.tsx @@ -25,8 +25,8 @@ export function ErrorDetails(props: ErrorDetailsProps) { > - - + + ) diff --git a/boilerplate/app/screens/LoginScreen.tsx b/boilerplate/app/screens/LoginScreen.tsx index bcac21fcd..ac82adca6 100644 --- a/boilerplate/app/screens/LoginScreen.tsx +++ b/boilerplate/app/screens/LoginScreen.tsx @@ -78,10 +78,10 @@ export const LoginScreen: FC = observer(function LoginScreen(_ contentContainerStyle={themed($screenContentContainer)} safeAreaEdges={["top", "bottom"]} > - - + + {attemptsCount > 2 && ( - + )} = observer(function LoginScreen(_ autoComplete="email" autoCorrect={false} keyboardType="email-address" - labelTx="loginScreen.emailFieldLabel" - placeholderTx="loginScreen.emailFieldPlaceholder" + labelTx="loginScreen:emailFieldLabel" + placeholderTx="loginScreen:emailFieldPlaceholder" helper={error} status={error ? "error" : undefined} onSubmitEditing={() => authPasswordInput.current?.focus()} @@ -108,15 +108,15 @@ export const LoginScreen: FC = observer(function LoginScreen(_ autoComplete="password" autoCorrect={false} secureTextEntry={isAuthPasswordHidden} - labelTx="loginScreen.passwordFieldLabel" - placeholderTx="loginScreen.passwordFieldPlaceholder" + labelTx="loginScreen:passwordFieldLabel" + placeholderTx="loginScreen:passwordFieldPlaceholder" onSubmitEditing={login} RightAccessory={PasswordRightAccessory} />