1.0.5 • Published 6 months ago

kros-i18n v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

next-kros-i18n

A React library for seamless internationalization using Kros AI translation services.

Installation

npm install next-kros-i18n

Usage

  1. 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>
    );
}
  1. 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

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago