mirror of https://github.com/vector-im/riot-web
Switch to stock counterpart
We no longer need the custom counterpart. The things that were changed in it and reasosn we no lomger need them are: 1. set separator - this can be done with standard counterpart 2. ES6 port: this was done to allow importing as _t, but is unnecessary with the _t wrapper function in react-sdk (although also seems to work fine with `import _t from 'counterpart';`) 3. Fallback to key name: unnecessary with `setMissingEntryGenerator` in 0.18, but we've changed to just using a fallback locale anyway since No code missing en translations should ever make it to the devbelop branch. 4. Logging on missing translations. Unnecessary with `onTranslationNotFound`, but now not used anyway because we let missing translations show up in the UI as 'missing translation' Bulk changes to imports coming in separate commit for easy reading.pull/21833/head
parent
b677a2002f
commit
ec146c7f45
|
@ -50,7 +50,7 @@
|
||||||
"browser-request": "^0.3.3",
|
"browser-request": "^0.3.3",
|
||||||
"classnames": "^2.1.2",
|
"classnames": "^2.1.2",
|
||||||
"commonmark": "^0.27.0",
|
"commonmark": "^0.27.0",
|
||||||
"counterpart-riot": "^0.18.1",
|
"counterpart": "^0.18.0",
|
||||||
"draft-js": "^0.8.1",
|
"draft-js": "^0.8.1",
|
||||||
"draft-js-export-html": "^0.5.0",
|
"draft-js-export-html": "^0.5.0",
|
||||||
"draft-js-export-markdown": "^0.2.0",
|
"draft-js-export-markdown": "^0.2.0",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2017 MTRNord and Cooperative EITA
|
Copyright 2017 MTRNord and Cooperative EITA
|
||||||
|
Copyright 2017 Vector Creations Ltd.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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';
|
import request from 'browser-request';
|
||||||
// Workaround for broken export
|
import counterpart from 'counterpart';
|
||||||
import * as counterpart from 'counterpart-riot';
|
|
||||||
import UserSettingsStore from './UserSettingsStore';
|
|
||||||
import q from 'q';
|
import q from 'q';
|
||||||
|
|
||||||
|
import UserSettingsStore from './UserSettingsStore';
|
||||||
|
|
||||||
const i18nFolder = 'i18n/';
|
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) {
|
export function setLanguage(languages, extCounterpart=null) {
|
||||||
if (!languages || !Array.isArray(languages)) {
|
if (!languages || !Array.isArray(languages)) {
|
||||||
const languages = this.getNormalizedLanguageKeys(this.getLanguageFromBrowser());
|
const languages = this.getNormalizedLanguageKeys(this.getLanguageFromBrowser());
|
||||||
|
|
Loading…
Reference in New Issue