AkiLocale
A localization library for Akinon applications. Wraps i18next with a simplified API for managing translations.
Installation
pnpm add @akinon/akilocaleBasic Usage
import { Akilocale } from '@akinon/akilocale';
// Create a locale instance with translations
const locale = Akilocale.createInstance({
fallbackLng: 'en',
translations: {
en: {
greeting: 'Hello',
welcome: 'Welcome, {{name}}!'
},
tr: {
greeting: 'Merhaba',
welcome: 'Hoş geldin, {{name}}!'
}
}
});
// Use the translation function
locale.t('greeting'); // "Hello" or "Merhaba" based on current language
locale.t('welcome', { name: 'John' }); // "Welcome, John!"
// Get current language
console.log(locale.lng); // "en"API Reference
Akilocale.createInstance
Option
Type
Default
Description
Property
Type
Description
Akilocale.setLanguage
Parameter
Type
Description
Translation Function (t)
Translation Structure
React Integration
Language Persistence
Language Priority
Common Use Cases
App Initialization
Language Switcher
Integration with Akidate
With Intl APIs
Table with Translations
Translation File Organization
JSON Files (Recommended)
TypeScript Files
Best Practices
Related
Last updated
Was this helpful?

