Skip to main content

View Internationalization

The View package includes comprehensive internationalization support, allowing you to create multilingual UI components.

Overview

The View package’s internationalization features include:
  • Integration with next-intl for translations
  • Support for multiple locales (English, Turkish, Spanish, German)
  • Translation files for all view components
  • Hooks for accessing translations in React components
  • Automatic locale detection and switching

Configuration

The View package uses the same internationalization configuration as the rest of the framework:

Translation Files

Translation files are stored in both the dictionaries/ and locales/ directories:
Each locale file contains translations for view components:

API Reference

useViewTranslations

Hook for accessing translations in React components.

setViewLocale

Function for setting the current locale.

getViewLocale

Function for getting the current locale.

withViewTranslations

Higher-order component for providing translations to components.

Examples

Using useViewTranslations in a Component

Using Translations with Parameters

Setting the Locale

Using withViewTranslations HOC

Integration with Next.js

The View package integrates with Next.js internationalization using next-international and next-intl:

Adding New Translations

To add translations for a new key:
  1. Add the key to all locale files (en.json, tr.json, es.json, de.json)
  2. Use the key in your components with useViewTranslations

Adding Support for New Languages

To add support for a new language:
  1. Create a new locale file in the locales/ directory (e.g., fr.json)
  2. Add the locale to the supported locales in the configuration
  3. Translate all keys from the English locale file
Update the configuration to include the new locale: