Skip to main content

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

Quick Start

Using Translations in Components

There are two main ways to use translations: 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 in app/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:

Interpolation (Dynamic Values)

Use {{variable}} syntax for dynamic values:

Language Switching

Programmatic Language Change

Built-in Language Selector

Shipnative includes a LanguageSelector 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

  1. Create the language file:
  1. Register in i18n config:
  1. Add to language selector:

Testing Translations

To verify translations are working:
  1. Change language in Profile settings
  2. Use the language selector component
  3. 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 tx prop

TypeScript Errors for Valid Keys

  • Run yarn typecheck to regenerate types
  • Ensure en.ts exports the Translations type

RTL Layout Issues

  • Check that I18nManager.allowRTL(true) is called
  • Some custom styles may need flexDirection: 'row-reverse' for RTL