twilio / twilio-conversations-demo-react

Twilio Conversations Demo Web Application
MIT License
96 stars 295 forks source link

feat: Added localization support #143

Closed lesquive closed 7 months ago

lesquive commented 9 months ago

Description

Added localization support and user language preference storage.

Changes Made

Details

The localUtils.tsx file contains utility functions for managing language translations. It allows the addition of more languages by simply updating the translations and languageOptions variables.

export const languageOptions: {
  languages: LanguageOption[];
} = {
  languages: [
    {
      code: "en-US",
      flag: "🇺🇸",
    },
    {
      code: "es-ES",
      flag: "🇪🇸",
    },
    {
      code: "fr-FR",
      flag: "🇫🇷",
    },
    // Add more languages if needed
  ],
};

export const translations: Translations = {
  "en-US": {
    greeting: "Select a conversation on the left to get started.",
    online: "Online",
    connecting: "Connecting",
     // Add other error keys and their respective translations
  },
  "es-ES": {
    greeting: "Seleccione una conversación a la izquierda para comenzar.",
    online: "En línea",
    connecting: "Conectando",
     // Add other error keys and their respective translations
  },
  "fr-FR": {
    greeting: "Sélectionnez une conversation sur la gauche pour commencer.",
    online: "En ligne",
    connecting: "Connexion",
     // Add other error keys and their respective translations
  },
  // Add translations for other languages as needed
};

Before:

After:

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.