import LocalizedStrings from 'react-localization';

const strings = new LocalizedStrings({
  en: {
    colonize: (input: string): any => strings.formatString('{0}:', input),

    save: 'Save',
    cancel: 'Cancel',
    close: 'Close',
    settings: 'Settings',
    language: 'Language',
    user: 'User',
    pseudo: 'Pseudo',
    geolocation: 'Geolocation',
    minTimeInt: 'Minimal time interval (ms)',
    minDist: 'Minimal distance (m)',

    trackRecording: 'Track recording',
    resumeRecording: 'Resume recording',
    startRecording: 'Start recording',
    pauseRecording: 'Pause',
    //    stopRecording: 'stop',
    //    cancelRecording: 'cancel',
    stopRecording: (
      <>
        Stop recording
        <br />
        (and save track)
      </>
    ),
    cancelRecording: (
      <>
        Cancel recording
        <br />
        (and clear track)
      </>
    ),

    chooseYourMap: 'Choose your map',

    languageSelect: {
      placeHolder: 'Select your language',
      choices: [
        { value: 'auto', label: 'Automatic' },
        { value: 'en', label: 'English' },
        { value: 'fr', label: 'Français' },
      ],
    },

    tracks: 'Tracks',

    locationInfo: {
      title: 'Here',
      location: 'Location',
      lat: 'Latitude: ',
      lon: 'Longitude: ',
      elevation: 'Elevation:',
      address: 'Address',
      display_name: 'Full address:',
    },
  },
  fr: {
    colonize: (input: string): any => strings.formatString('{0} :', input),

    save: 'Sauvegarder',
    cancel: 'Annuler',
    close: 'Fermer',
    settings: 'Paramètres',
    language: 'Langue',
    user: 'Utilisateur',
    pseudo: 'Pseudo',
    geolocation: 'Géolocalisation',
    minTimeInt: 'Interval minimal (ms)',
    minDist: 'Distance minimale (m)',

    trackRecording: 'Enregistrement de trace',
    resumeRecording: (
      <>
        Reprendre
        <br />
        l'enregistrement
      </>
    ),
    startRecording: (
      <>
        Démarre
        <br />
        l'enregistrement
      </>
    ),
    pauseRecording: 'Pause',
    stopRecording: (
      <>
        Arrêter
        <br />
        (et sauvegarder)
      </>
    ),
    cancelRecording: (
      <>
        Annuler
        <br />
        (et effacer)
      </>
    ),

    chooseYourMap: 'Choisissez votre carte',

    languageSelect: {
      placeHolder: 'Selectionner votre langue',
      choices: [
        { value: 'auto', label: 'Automatique' },
        { value: 'fr', label: 'Français' },
        { value: 'en', label: 'English' },
      ],
    },

    tracks: 'Traces',

    locationInfo: {
      title: 'Ici',
      location: 'Position',
      lat: 'Latitude : ',
      lon: 'Longitude : ',
      elevation: 'Altitude :',
      address: 'Addresse',
      display_name: 'Adresse complète :',
    },
  },
});

export default strings;

export const setI18nLanguage = (language: string) => {
  if (language === undefined || language === 'auto') {
    strings.setLanguage(strings.getInterfaceLanguage());
  } else {
    strings.setLanguage(language);
  }
};
