Permalink
Browse files

retrieve language json files

  • Loading branch information...
karimJWP karimJWP
karimJWP authored and karimJWP committed Sep 13, 2018
1 parent e0e57e9 commit f83335c34ec3391ae54116dcb0e03e57394a6453
Showing with 10 additions and 5 deletions.
  1. +1 −1 src/js/api/core-shim.js
  2. +1 −1 src/js/utils/ajax.js
  3. +3 −3 src/js/utils/language.js
  4. +5 −0 webpack.config.js
@@ -87,7 +87,7 @@ Object.assign(CoreShim.prototype, {
const setupConfig = options;
const configuration = Config(Object.assign({}, options), persisted);
configuration.id = api.id;
loadJsonTranslation('la', (result) => {
loadJsonTranslation(configuration.base, 'la', (result) => {
console.log('result: ', result);
}, (error) => {
console.log('fallaste: ', error);
@@ -36,7 +36,7 @@ export function ajax(url, completeCallback, errorCallback, args) {
onerror: errorCallback || noop,
mimeType: (args && !args.responseType) ? 'text/xml' : '',
requireValidXML: false, /* Require responseXML */
responseType: (args && args.plainText) ? 'text' : '', /* xhr.responseType ex: "json" or "text" */
responseType: args && args.responseType || (args && args.plainText) ? 'text' : '', /* xhr.responseType ex: "json" or "text" */
useDomParser: false,
requestFilter: null
}, args);
@@ -71,7 +71,7 @@ export function isTranslationAvailable(language) {
// return loadPromise;
// }
export function loadJsonTranslation(languageCode, successHandler, errorHandler) {
const translation = languageCode + '.json';
ajax(translation, successHandler, errorHandler);
export function loadJsonTranslation(base, languageCode, successHandler, errorHandler) {
const path = base + 'translations/' + languageCode + '.json';
ajax(path, successHandler, errorHandler, { responseType: 'json' });
}
@@ -157,6 +157,11 @@ const multiConfig = [
{
test: /\.svg$/,
loader: 'svg-inline-loader'
},
{
type: 'javascript/auto',
test: /\.json$/,
loader: 'file-loader'
}
]
}

0 comments on commit f83335c

Please sign in to comment.