@umituz/react-native-localization 3.5.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ export interface TranslationOptions {
|
|
|
15
15
|
count?: number;
|
|
16
16
|
ns?: string | string[];
|
|
17
17
|
defaultValue?: string;
|
|
18
|
-
[key: string]:
|
|
18
|
+
[key: string]: unknown;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -29,11 +29,12 @@ export interface TranslationOptions {
|
|
|
29
29
|
export const useTranslationFunction = () => {
|
|
30
30
|
const { t: i18nextT, ready } = useTranslation(undefined, { i18n });
|
|
31
31
|
|
|
32
|
-
const translate = useCallback((key: string,
|
|
32
|
+
const translate = useCallback((key: string, defaultValueOrOptions?: string | TranslationOptions): string => {
|
|
33
|
+
const options: TranslationOptions = typeof defaultValueOrOptions === 'string'
|
|
34
|
+
? { defaultValue: defaultValueOrOptions }
|
|
35
|
+
: defaultValueOrOptions || {};
|
|
36
|
+
|
|
33
37
|
if (!ready || !i18n.isInitialized) {
|
|
34
|
-
if (__DEV__) {
|
|
35
|
-
console.warn(`[Localization] i18n not ready, returning key: ${key}`);
|
|
36
|
-
}
|
|
37
38
|
return options.defaultValue || key;
|
|
38
39
|
}
|
|
39
40
|
|