Merge branch 'recogito:main' into i18n-french
This commit is contained in:
commit
1f31e2d74c
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@recogito/recogito-client-core",
|
||||
"version": "1.3.5",
|
||||
"version": "1.4.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@recogito/recogito-client-core",
|
||||
"version": "1.3.5",
|
||||
"version": "1.4.4",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "^7.10.4",
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"name": "@recogito/recogito-client-core",
|
||||
"version": "1.3.5",
|
||||
"version": "1.4.4",
|
||||
"description": "Core functions, classes and components for RecogitoJS",
|
||||
"main": "src/index.js",
|
||||
"sideEffects": ["themes/default/*"],
|
||||
"scripts": {
|
||||
"test": "NODE_ENV=test ./node_modules/.bin/mocha --require @babel/register"
|
||||
},
|
||||
|
|
|
@ -13,7 +13,8 @@ export const PURPOSES = [
|
|||
{'value': 'linking', 'label': 'Linking'},
|
||||
{'value': 'moderating', 'label': 'Moderating'},
|
||||
{'value': 'questioning', 'label': 'Questioning'},
|
||||
{'value': 'replying', 'label': 'Replying'}
|
||||
{'value': 'replying', 'label': 'Replying'},
|
||||
{'value': 'supplementing', 'label': 'Transcription'}
|
||||
]
|
||||
|
||||
const PurposeSelect = props => {
|
||||
|
@ -34,4 +35,4 @@ const PurposeSelect = props => {
|
|||
|
||||
}
|
||||
|
||||
export default PurposeSelect;
|
||||
export default PurposeSelect;
|
||||
|
|
|
@ -59,22 +59,34 @@ const isReactComponent = component => {
|
|||
*/
|
||||
export const getWidget = arg => {
|
||||
|
||||
const instantiate = (widget, config) => {
|
||||
const instantiate = (widget, config, force) => {
|
||||
// Check if user forced explicit type
|
||||
if (typeof widget === 'string' || widget instanceof String) {
|
||||
// Built-in
|
||||
return React.createElement(BUILTIN_WIDGETS[widget], config);
|
||||
} else if (isReactComponent(widget)) {
|
||||
return React.createElement(widget, config);
|
||||
} else if (typeof widget === 'function' || widget instanceof Function) {
|
||||
return <WrappedWidget widget={widget} config={config} />
|
||||
} else {
|
||||
throw `${widget} is not a valid plugin`
|
||||
} else {
|
||||
// Plugin
|
||||
if (force?.toLowerCase() === 'react') {
|
||||
return React.createElement(widget, config);
|
||||
} else if (force?.toLowerCase() === 'plainjs') {
|
||||
return <WrappedWidget widget={widget} config={config} />
|
||||
} else {
|
||||
// Auto-detect
|
||||
if (isReactComponent(widget)) {
|
||||
return React.createElement(widget, config);
|
||||
} else if (typeof widget === 'function' || widget instanceof Function) {
|
||||
return <WrappedWidget widget={widget} config={config} />
|
||||
} else {
|
||||
throw `${widget} is not a valid plugin`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// First, check 'top-level' vs. 'nested object' case
|
||||
if (arg.widget) {
|
||||
const { widget, ...config } = arg;
|
||||
return instantiate(widget, config);
|
||||
const { widget, force, ...config } = arg;
|
||||
return instantiate(widget, config, force);
|
||||
} else {
|
||||
// No object with args -> instantiate arg directly
|
||||
return instantiate(arg);
|
||||
|
|
|
@ -1,12 +1,42 @@
|
|||
import Polyglot from 'node-polyglot';
|
||||
import * as timeago from 'timeago.js';
|
||||
|
||||
import messages_ar from './messages_ar.json';
|
||||
import messages_cs from './messages_cs.json';
|
||||
import messages_de from './messages_de.json';
|
||||
import messages_el from './messages_el.json';
|
||||
import messages_es from './messages_es.json';
|
||||
import messages_gl from './messages_gl.json';
|
||||
import messages_hi from './messages_hi.json';
|
||||
import messages_it from './messages_it.json';
|
||||
import messages_nl from './messages_nl.json';
|
||||
import messages_pt from './messages_pt.json';
|
||||
import messages_sv from './messages_sv.json';
|
||||
import messages_tr from './messages_tr.json';
|
||||
import messages_ur from './messages_ur.json';
|
||||
|
||||
const MESSAGES = {
|
||||
ar: messages_ar,
|
||||
cs: messages_cs,
|
||||
de: messages_de,
|
||||
el: messages_el,
|
||||
es: messages_es,
|
||||
gl: messages_gl,
|
||||
hi: messages_hi,
|
||||
it: messages_it,
|
||||
nl: messages_nl,
|
||||
pt: messages_pt,
|
||||
sv: messages_sv,
|
||||
tr: messages_tr,
|
||||
ur: messages_ur
|
||||
}
|
||||
|
||||
const i18n = new Polyglot({ allowMissing: true });
|
||||
|
||||
i18n.init = (lang, opt_messages) => {
|
||||
if (lang) {
|
||||
i18n.locale(lang);
|
||||
i18n.extend(require(`./messages_${lang}.json`));
|
||||
i18n.extend(MESSAGES[lang]);
|
||||
}
|
||||
|
||||
if (opt_messages)
|
||||
|
|
Loading…
Reference in New Issue