
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@translata/react
Advanced tools
Provides a react integration for Translata.
yarn add @translata/core @translata/react
Create a translator provider using a default locale and a factory function. The factory function gets the current active locale and should return a setup translator function which is created by createTranslator:
// AppTranslator.ts
import { createTranslator, withTranslations, withDefaultLocale } from '@translata/core';
import { createTranslatorProvider } from '@translata/react';
export default createTranslatorProvider('en', locale => createTranslator(
withTranslations('en', {
'message.greeting': 'Hello!',
'button.de': 'Goto german',
'button.en': 'Goto english'
}),
withTranslations('en', {
'message.greeting': 'Hallo!',
'button.de': 'Wechsel zu Deutsch',
'button.en': 'Wechsel zu Englisch'
})
withDefaultLocale(locale)
));
Wrap this Provider around your application:
// App.tsx
import AppTranslator from './AppTranslator';
import Component from './Component';
export default () => {
return (
<AppTranslator>
<Component />
</AppTranslator>
);
}
Use the translator context inside your components:
// Component.tsx
import AppTranslator from './AppTranslator';
export default () => {
// get the actual translator function.
const _ = AppTranslator.useTranslator();
// get the current active locale.
const locale = AppTranslator.useLocale();
// get a locale setter to change the locale on the context.
// this will reinvoke your translator factory function passed to createTranslatorProvider().
const setLocale = AppTranslator.useSetLocale();
// callback to change locale to "de"
const setLocaleToDe = useCallback(() => {
setLocale('de');
}, [])
// callback to change locale to "en"
const setLocaleToEn = useCallback(() => {
setLocale('en');
}, [])
// use the translata as you would without react.
return (
<div>
{_('message.greeting')}
<button disabled={locale === 'de'} onClick={setLocaleToDe}>{_('button.de')}</button>
<button disabled={locale === 'en'} onClick={setLocaleToDe}>{_('button.en')}</button>
</div>
);
}
FAQs
React integration for translata: The Composable Translation Utility
We found that @translata/react 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.