
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-culture-text
Advanced tools
A higher order component of <Text/> to provide i18n features in a react-friendly way
A higher order component of <Text/> to provide i18n features in a react-friendly way
Current i18n libraries implement translations in an app-wide manner. This generates a coupling that works againts component isolation. We need a way in which each component can define their owns translations, in a standalone manner. This is somehow similar to the concept handling local styles instead of having global rules.
<Text/> elements depending on the context's cultureyarn add react-native-culture-text
<CultureContext locale={'es-AR'} /> to tell all the children in the hierarchy what's the current locale of the user.<CultureContext translations={myTranslations} /> to tell the component's children where to look for translated messages.<Text/> component that comes with this library instead of the original react-native one.<Text/> element, add a new attribute messageKey that will be used to select which message translation to use.<Text/> component, wrap your UI with a <CultureFragment/> component use the children render prop that provides a translate helper functionimport React, { Component } from 'react';
import {
View
} from 'react-native';
import {
CultureContext,
Text
} from 'react-native-culture-text';
export default class example extends Component {
render() {
return (
<CultureContext translations={translations} locale="es">
<View>
<Text>
Welcome to React Native!
</Text>
<Text messageKey="welcome">
This text depends on the selected culture
</Text>
</View>
</CultureContext>
);
}
}
const translations = {
en: {
welcome: 'This text depends on the selected culture',
},
es: {
welcome: 'Este texto depende de la cultura seleccionada',
},
}
import React, { Component } from 'react';
import {
View,
TextInput
} from 'react-native';
import {
CultureContext,
CultureFragment
} from 'react-native-culture-text';
export default class example extends Component {
render() {
return (
<CultureContext translations={translations} locale="es">
<CultureFragment>
{T => (
<View>
<Text>
Welcome to React Native!
</Text>
<TextInput placeholder={T('username')} />
)}
</View>
</CultureFragment>
</CultureContext>
);
}
}
const translations = {
en: {
username: 'type your username',
},
es: {
username: 'ingrese su usuario',
},
}
FAQs
A higher order component of <Text/> to provide i18n features in a react-friendly way
We found that react-native-culture-text demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.