From f412552c2c8326edaa6d107c7e3c3d68b8fbe022 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 23 May 2017 18:32:45 +0100 Subject: [PATCH] Fix imports/exports --- src/components/structures/UserSettings.js | 2 +- src/components/views/elements/LanguageDropdown.js | 2 +- src/languageHandler.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index ff3d2e774c..12bd9fc0d6 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -30,7 +30,7 @@ const AddThreepid = require('../../AddThreepid'); const SdkConfig = require('../../SdkConfig'); import AccessibleButton from '../views/elements/AccessibleButton'; import _t from 'counterpart-riot'; -const languageHandler = require('../../languageHandler'); +import * as languageHandler from('../../languageHandler'); import * as FormattingUtils from '../../utils/FormattingUtils'; // if this looks like a release, use the 'version' from package.json; else use diff --git a/src/components/views/elements/LanguageDropdown.js b/src/components/views/elements/LanguageDropdown.js index 4feec57df8..27ce8efaab 100644 --- a/src/components/views/elements/LanguageDropdown.js +++ b/src/components/views/elements/LanguageDropdown.js @@ -19,7 +19,7 @@ import React from 'react'; import sdk from '../../../index'; import UserSettingsStore from '../../../UserSettingsStore'; import _t from 'counterpart-riot'; -import languageHandler from '../../../languageHandler'; +import * as languageHandler from '../../../languageHandler'; import SdkConfig from '../../../SdkConfig'; let LANGUAGES = []; diff --git a/src/languageHandler.js b/src/languageHandler.js index e22e93d664..92e3ccefb6 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -18,11 +18,11 @@ import request from 'browser-request'; // Workaround for broken export import * as counterpart from 'counterpart-riot'; import UserSettingsStore from './UserSettingsStore'; -var q = require('q'); +import q from 'q'; const i18nFolder = 'i18n/'; -module.exports.setLanguage = function(languages, extCounterpart=null) { +export function setLanguage(languages, extCounterpart=null) { if (!languages || !Array.isArray(languages)) { const languages = this.getNormalizedLanguageKeys(this.getLanguageFromBrowser()); console.log("no language found. Got from browser: " + JSON.stringify(languages)); @@ -112,7 +112,7 @@ module.exports.setLanguage = function(languages, extCounterpart=null) { }); }; -module.exports.getAllLanguageKeysFromJson = function() { +export function getAllLanguageKeysFromJson() { let deferred = q.defer(); request( @@ -139,11 +139,11 @@ module.exports.getAllLanguageKeysFromJson = function() { return deferred.promise; } -module.exports.getLanguageFromBrowser = function() { +export function getLanguageFromBrowser() { return navigator.languages[0] || navigator.language || navigator.userLanguage; }; -module.exports.getNormalizedLanguageKeys = function(language) { +export function getNormalizedLanguageKeys(language) { if (!language) { return; } @@ -161,6 +161,6 @@ module.exports.getNormalizedLanguageKeys = function(language) { return languageKeys; }; -module.exports.normalizeLanguageKey = function(language) { +export function normalizeLanguageKey(language) { return language.toLowerCase().replace("_","-"); };