1.0.5 • Published 6 months ago
kros-i18n v1.0.5
next-kros-i18n
A React library for seamless internationalization using Kros AI translation services.
Installation
npm install next-kros-i18n
Usage
- Wrap your app with KrosI18nProvider:
import { KrosI18nProvider, useTranslation } from 'next-kros-i18n';
function App() {
return (
<KrosI18nProvider
apiKey={process.env.NEXT_PUBLIC_KROS_API_KEY}
autoDetect={true}
supportedLanguages={['en', 'fr', 'es']}
>
{/ Your app components /}
</KrosI18nProvider>
);
}
- Use the translation hook in your components:
import { useTranslation } from 'next-kros-i18n';
function MyComponent() {
const { t, currentLanguage, setLanguage } = useTranslation();
return (
<div>
<h1>{await t('Welcome')}</h1>
<p>Current language: {currentLanguage}</p>
<button onClick={() => setLanguage('fr')}>
Switch to French
</button>
</div>
);
}
Features
- 🌍 Automatic language detection
- 🔄 Easy language switching
- 💾 Translation caching
- ⚡ Async translation support
- 🔧 Configurable settings
- 📦 TypeScript support
API Reference
KrosI18nProvider
Provider component that wraps your app...
Continue with full API documentation
License
ISC