Sha256: 1941ab401cfdf7bd06138e374b1f5360c09c6c204cf54e6349b806dd0f472876

Contents?: true

Size: 806 Bytes

Versions: 9

Compression:

Stored size: 806 Bytes

Contents

import flatpickr from 'flatpickr'

// Container for i18n translations
export const i18n = {}

// Some of Flatpickr's locale names differ from Rails. This maps the Rails I18n locale to their Flatpickr equivalent.
const FlatpickrLocaleConversions = { ca: 'cat', el: 'gr', nb: 'no', vi: 'vn' }

// Sets up localization for Trestle and its dependencies, in particular Flatpickr.
// This method accepts a list of locales in descending order of priority.
//
//     Trestle.localize('es-MX', 'es', 'en')
//
export function localize () {
  for (var i = 0; i < arguments.length; ++i) {
    var locale = arguments[i]
    var flatpickrLocale = FlatpickrLocaleConversions[locale] || locale

    if (flatpickr.l10ns[flatpickrLocale]) {
      flatpickr.localize(flatpickr.l10ns[flatpickrLocale])
      break
    }
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
trestle-0.9.8 frontend/js/core/i18n.js
trestle-0.9.7 frontend/js/core/i18n.js
trestle-0.9.6 frontend/js/core/i18n.js
trestle-0.9.5 frontend/js/core/i18n.js
trestle-0.9.4 frontend/js/core/i18n.js
trestle-0.9.3 frontend/js/core/i18n.js
trestle-0.9.2 frontend/js/core/i18n.js
trestle-0.9.1 frontend/js/core/i18n.js
trestle-0.9.0 frontend/js/core/i18n.js