diff --git a/package.json b/package.json index 11106325f1..b94c8d66eb 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "browser-request": "^0.3.3", "classnames": "^2.1.2", "commonmark": "^0.27.0", - "counterpart-riot": "^0.18.1", + "counterpart": "^0.18.0", "draft-js": "^0.8.1", "draft-js-export-html": "^0.5.0", "draft-js-export-markdown": "^0.2.0", diff --git a/src/languageHandler.js b/src/languageHandler.js index 92e3ccefb6..25c380a53c 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -1,5 +1,6 @@ /* Copyright 2017 MTRNord and Cooperative EITA +Copyright 2017 Vector Creations Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,13 +16,27 @@ limitations under the License. */ import request from 'browser-request'; -// Workaround for broken export -import * as counterpart from 'counterpart-riot'; -import UserSettingsStore from './UserSettingsStore'; +import counterpart from 'counterpart'; import q from 'q'; +import UserSettingsStore from './UserSettingsStore'; + const i18nFolder = 'i18n/'; +// We use english strings as keys, some of which contain full stops +counterpart.setSeparator('|'); +// Fall back to English +counterpart.setFallbackLocale('en'); + +// The translation function. This is just a simple wrapper to counterpart, +// but exists mostly because we must use the same counterpart instance +// between modules (ie. here (react-sdk) and the app (riot-web), and if we +// just import counterpart and use it directly, we end up using a different +// instance. +export function _t(...args) { + return counterpart.translate(...args); +} + export function setLanguage(languages, extCounterpart=null) { if (!languages || !Array.isArray(languages)) { const languages = this.getNormalizedLanguageKeys(this.getLanguageFromBrowser());