Skip to main content

One post tagged with "usetranslator"

View All Tags

How to translate input placeholder

Maksim Sharipov

Maksim Sharipov

Maintainer of eo-locale

Translate input placeholder is quite common task. Let's consider how we can do it with eo-locale.

import { TranslationsProvider, useTranslator } from '@eo-locale/react';
const LOCALES = [{
language: 'en',
messages: {
hello: 'Hello World!',
}
}]
function App() {
return (
<TranslationsProvider language="en" locales={LOCALES}>
<SomeComponent />
</TranslationsProvider>
);
}
function SomeComponent() {
const translator = useTranslator();
return <input placeholder={translator.translate('hello')} />
}