From c612902779d8ac890726f443d5fbb74de5b53f0a Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 17 Jan 2018 13:41:02 -0700 Subject: [PATCH] fixed styles --- client/coral-framework/services/bootstrap.js | 6 +----- client/coral-framework/services/i18n.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/coral-framework/services/bootstrap.js b/client/coral-framework/services/bootstrap.js index 912c6c532..b1014f2db 100644 --- a/client/coral-framework/services/bootstrap.js +++ b/client/coral-framework/services/bootstrap.js @@ -5,7 +5,7 @@ import EventEmitter from 'eventemitter2'; import { createReduxEmitter } from './events'; import { createRestClient } from './rest'; import thunk from 'redux-thunk'; -import { setupTranslations, loadTranslations } from './i18n'; +import { loadTranslations } from './i18n'; import bowser from 'bowser'; import noop from 'lodash/noop'; import { BASE_PATH } from 'coral-framework/constants/url'; @@ -88,10 +88,6 @@ export async function createContext({ const pymStorage = createPymStorage(pym); const history = createHistory(BASE_PATH); const introspection = createIntrospection(introspectionData); - - // Setup the translation framework with the storage. - setupTranslations(storage); - let store = null; const token = () => { // Try to get the token from localStorage. If it isn't here, it may diff --git a/client/coral-framework/services/i18n.js b/client/coral-framework/services/i18n.js index 4c387a0ca..91f8560cc 100644 --- a/client/coral-framework/services/i18n.js +++ b/client/coral-framework/services/i18n.js @@ -3,14 +3,14 @@ import has from 'lodash/has'; import get from 'lodash/get'; import merge from 'lodash/merge'; -import { createStorage } from 'coral-framework/services/storage'; - import moment from 'moment'; import 'moment/locale/da'; import 'moment/locale/es'; import 'moment/locale/fr'; import 'moment/locale/pt-br'; +import { createStorage } from 'coral-framework/services/storage'; + import daTA from 'timeago.js/locales/da'; import esTA from 'timeago.js/locales/es'; import frTA from 'timeago.js/locales/fr'; @@ -52,20 +52,21 @@ function setLocale(storage, locale) { function getLocale(storage) { try { - const locale = ( + return ( (storage && storage.getItem('locale')) || navigator.language || defaultLanguage ).split('-')[0]; - - return locale; } catch (err) { console.error(err); return null; } } -export function setupTranslations(storage) { +export function setupTranslations() { + // Setup the translation framework with the storage. + const storage = createStorage(); + const locale = getLocale(storage); setLocale(storage, locale); @@ -124,3 +125,6 @@ export function t(key, ...replacements) { } export default t; + +// Setup the translations globally as soon as this module runs. +setupTranslations();