@umituz/react-native-localization 3.4.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
|
|
|
@@ -32,7 +32,7 @@ export const LanguageSection: React.FC<LanguageSectionProps> = ({
|
|
|
32
32
|
const { t, currentLanguage } = useLocalization();
|
|
33
33
|
|
|
34
34
|
const route = config?.route || 'LanguageSelection';
|
|
35
|
-
const title = config?.title || t('settings.
|
|
35
|
+
const title = config?.title || t('settings.languageSelection.title') || 'Language';
|
|
36
36
|
const description = config?.description || '';
|
|
37
37
|
|
|
38
38
|
const currentLang = getLanguageByCode(currentLanguage);
|
|
@@ -47,7 +47,7 @@ export const LanguageSection: React.FC<LanguageSectionProps> = ({
|
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<View style={[styles.sectionContainer, { backgroundColor: colors.surface }, containerStyle]}>
|
|
50
|
-
<Text style={[styles.sectionTitle, { color: colors.textPrimary }]}>{
|
|
50
|
+
<Text style={[styles.sectionTitle, { color: colors.textPrimary }]}>{title}</Text>
|
|
51
51
|
|
|
52
52
|
<Pressable
|
|
53
53
|
style={({ pressed }) => [
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from 'react-native';
|
|
15
15
|
// @ts-ignore - Optional peer dependency
|
|
16
16
|
import { useNavigation } from '@react-navigation/native';
|
|
17
|
+
import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
|
|
17
18
|
import { useLocalization, searchLanguages, Language } from '../../index';
|
|
18
19
|
import { LanguageItem } from '../components/LanguageItem';
|
|
19
20
|
import { SearchInput } from '../components/SearchInput';
|
|
@@ -70,6 +71,7 @@ export const LanguageSelectionScreen: React.FC<LanguageSelectionScreenProps> = (
|
|
|
70
71
|
testID = 'language-selection-screen',
|
|
71
72
|
}) => {
|
|
72
73
|
const navigation = useNavigation();
|
|
74
|
+
const tokens = useAppDesignTokens();
|
|
73
75
|
const { t, currentLanguage, setLanguage } = useLocalization();
|
|
74
76
|
const [searchQuery, setSearchQuery] = useState('');
|
|
75
77
|
const [selectedCode, setSelectedCode] = useState(currentLanguage);
|
|
@@ -118,7 +120,7 @@ export const LanguageSelectionScreen: React.FC<LanguageSelectionScreenProps> = (
|
|
|
118
120
|
};
|
|
119
121
|
|
|
120
122
|
const content = (
|
|
121
|
-
<View style={[styles.container, customStyles?.container]} testID={testID}>
|
|
123
|
+
<View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }, customStyles?.container]} testID={testID}>
|
|
122
124
|
{renderSearchInputComponent()}
|
|
123
125
|
<FlatList
|
|
124
126
|
data={filteredLanguages}
|