i18n
The @akinon/app-client library provides built-in support for handling internationalization in your micro-frontend applications.
How It Works
Shell sets the current locale in shared data and broadcasts
LOCALE_CHANGEDeventsClient receives the locale via
useAppClient().localeClient can subscribe to locale changes via
onLocaleChangeClient updates its own i18n instance accordingly
Accessing Current Locale
Use the useAppClient hook to access the current locale:
import { useAppClient } from '@akinon/app-client';
const LocaleDisplay = () => {
const { locale } = useAppClient();
return <p>Current language: {locale}</p>;
};Subscribing to Locale Changes
Subscribe to locale changes to keep your application's translations in sync:
Complete Setup Example
Here's a complete example of setting up i18n in a client application:
Using with React-i18next Directly
If you prefer to use react-i18next directly instead of @akinon/akilocale:
Best Practices
1. Initialize Early
Set up locale management early in your application lifecycle, preferably at the top level:
2. Always Unsubscribe
Return the unsubscribe function to prevent memory leaks:
3. Handle Fallback Locale
Always have a fallback locale in case the received locale is not supported:
4. Lazy Load Translations
Consider lazy loading translations based on the current locale:
5. Minimize Re-renders
Handle locale changes at a high level to minimize re-renders:
Considerations
The initial locale defaults to
'en'if not provided by the shellLocale changes can occur at any time during user interaction
Ensure your application gracefully handles locale changes during data loading
Next Steps
Hooks - Complete hooks reference
Configuration - Application configuration
API Reference - Complete API documentation
Last updated
Was this helpful?

