Skip to content

Commit

Permalink
Merge pull request #109 from ewanharris/TIMOB-25790
Browse files Browse the repository at this point in the history
[TIMOB-25790] Do not override global L function to prevent error on iOS
  • Loading branch information
hansemannn committed Mar 31, 2018
2 parents a8f142e + 6398171 commit a5ee644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
17 changes: 6 additions & 11 deletions build/liveview.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@
this.loaded = false;
}

function L(name, filler) {
return (Module._globalCtx.localeStrings[Ti.Locale.currentLanguage] || {})[name] || filler || name;
}

// global namespace
global = Module._global = Module.global = {};

Expand Down Expand Up @@ -418,15 +422,6 @@
}

globalCtx.localeStrings = Module.require('localeStrings');
/**
* [description]
* @param {string} name [description]
* @param {string} filler [description]
* @return {string} [description]
*/
globalCtx.L = function (name, filler) {
return (globalCtx.localeStrings[Ti.Locale.currentLanguage] || {})[name] || filler || name;
};
Module.connectServer();
};

Expand Down Expand Up @@ -730,8 +725,8 @@
Module._compileList.push(this.id);
this.source = Module._wrap(src);
try {
var fn = new Function('exports, require, module, __filename, __dirname, lvGlobal', this.source); // eslint-disable-line no-new-func
fn(this.exports, Module.require, this, this.filename, this.__dirname, global);
var fn = new Function('exports, require, module, __filename, __dirname, lvGlobal, L', this.source); // eslint-disable-line no-new-func
fn(this.exports, Module.require, this, this.filename, this.__dirname, global, L);
} catch (err) {
process.emit('uncaughtException', { module: this.id, error: err, source: ('' + this.source).split('\n') });
}
Expand Down
17 changes: 6 additions & 11 deletions lib/platform/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function Module(id) {
this.loaded = false;
}

function L(name, filler) {
return (Module._globalCtx.localeStrings[Ti.Locale.currentLanguage] || {})[name] || filler || name;
}

// global namespace
global = Module._global = Module.global = {};

Expand Down Expand Up @@ -85,15 +89,6 @@ Module.patch = function (globalCtx, url, port) {
}

globalCtx.localeStrings = Module.require('localeStrings');
/**
* [description]
* @param {string} name [description]
* @param {string} filler [description]
* @return {string} [description]
*/
globalCtx.L = function (name, filler) {
return (globalCtx.localeStrings[Ti.Locale.currentLanguage] || {})[name] || filler || name;
};
Module.connectServer();
};

Expand Down Expand Up @@ -409,8 +404,8 @@ Module.prototype._compile = function () {
Module._compileList.push(this.id);
this.source = Module._wrap(src);
try {
const fn = new Function('exports, require, module, __filename, __dirname, lvGlobal', this.source); // eslint-disable-line no-new-func
fn(this.exports, Module.require, this, this.filename, this.__dirname, global);
const fn = new Function('exports, require, module, __filename, __dirname, lvGlobal, L', this.source); // eslint-disable-line no-new-func
fn(this.exports, Module.require, this, this.filename, this.__dirname, global, L);
} catch (err) {
process.emit('uncaughtException', { module: this.id, error: err, source: ('' + this.source).split('\n') });
}
Expand Down

0 comments on commit a5ee644

Please sign in to comment.