Sha256: 829983e1c1c572f18498b9ea199a17094c80154f08acd41251e7ad505d7e88e9

Contents?: true

Size: 766 Bytes

Versions: 11

Compression:

Stored size: 766 Bytes

Contents

/* eslint-disable no-param-reassign */
import { I18n }   from 'react-i18nify';
import requireAll from './require_all';

/**
 * Load components translations from yaml files and import them into
 * react-i18ify system so they can be used via `I18n.t` method.
 * @returns {Void} - Nothing
 */
const loadTranslations = () => {
  const translationsContext = require.context('../../../config/locales/', true, /\.yml$/);
  const translationFiles = requireAll(translationsContext);

  const translations = translationsContext.keys().reduce((acc, key, index) => {
    const locale = key.match(/\.\/(.*)\.yml/)[1];
    acc[locale] = translationFiles[index][locale].decidim;
    return acc;
  }, {});

  I18n.setTranslations(translations);
};

export default loadTranslations;

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
decidim-comments-0.0.6 app/frontend/support/load_translations.js
decidim-0.0.6 decidim-comments/app/frontend/support/load_translations.js
decidim-comments-0.0.5 app/frontend/support/load_translations.js
decidim-0.0.5 decidim-comments/app/frontend/support/load_translations.js
decidim-0.0.4 decidim-comments/app/frontend/support/load_translations.js
decidim-comments-0.0.3 app/frontend/support/load_translations.js
decidim-0.0.3 decidim-comments/app/frontend/support/load_translations.js
decidim-comments-0.0.2 app/frontend/support/load_translations.js
decidim-0.0.2 decidim-comments/app/frontend/support/load_translations.js
decidim-comments-0.0.1 app/frontend/support/load_translations.js
decidim-0.0.1 decidim-comments/app/frontend/support/load_translations.js