Internationalization (i18n)
Shipnative comes with a robust internationalization system built on i18next and react-i18next. The app supports 7 languages out of the box and makes it easy to add more.Supported Languages
| Language | Code | RTL Support |
|---|---|---|
| English | en | No |
| Arabic | ar | Yes |
| Spanish | es | No |
| French | fr | No |
| Hindi | hi | No |
| Japanese | ja | No |
| Korean | ko | No |
Quick Start
Using Translations in Components
There are two main ways to use translations:1. Using the tx Prop (Recommended for Static Text)
The Text component (and many other components) support a tx prop for translation keys:
2. Using the useTranslation Hook (For Dynamic Text)
When you need more control or want to use translations in logic:
Translation File Structure
Translation files are located inapp/i18n/:
Translation Key Structure
Translation keys are organized by screen/feature:Adding New Translations
Step 1: Add Keys to English File
English (en.ts) is the source of truth. Always add new keys here first:
Step 2: Update Other Language Files
Add the same keys to all other language files with translated values:Step 3: Use in Components
Component Support for tx Props
Many components support translation props directly:
| Component | Translation Props |
|---|---|
Text | tx, txOptions |
Button | tx, txOptions |
Badge | tx |
TextField | labelTx, placeholderTx, helperTx |
Card | headingTx, contentTx, footerTx |
Modal | titleTx, descriptionTx |
EmptyState | headingTx, contentTx, buttonTx |
Header | leftTx, rightTx |
AuthScreenLayout | titleTx, subtitleTx |
OnboardingScreenLayout | titleTx, subtitleTx |
Interpolation (Dynamic Values)
Use{{variable}} syntax for dynamic values:
Language Switching
Programmatic Language Change
Built-in Language Selector
Shipnative includes aLanguageSelector component:
Get Current Language
RTL (Right-to-Left) Support
Arabic is automatically detected and enables RTL layout:Type Safety
The i18n system provides full TypeScript support. Invalid keys will cause TypeScript errors:Best Practices
DO
DON’T
Adding a New Language
- Create the language file:
- Register in i18n config:
- Add to language selector:
Testing Translations
To verify translations are working:- Change language in Profile settings
- Use the language selector component
- Check for missing keys (they’ll display as the key path)
Troubleshooting
Translations Not Updating
- Ensure you’re importing from the correct i18n file
- Check that the key exists in the language file
- Verify the component supports the
txprop
TypeScript Errors for Valid Keys
- Run
yarn typecheckto regenerate types - Ensure
en.tsexports theTranslationstype
RTL Layout Issues
- Check that
I18nManager.allowRTL(true)is called - Some custom styles may need
flexDirection: 'row-reverse'for RTL
Related Resources
- i18next Documentation
- react-i18next Documentation
- Styling Guide - For RTL-aware styles

