tml-js-browser
Advanced tools
Comparing version 0.4.64 to 0.4.65
@@ -190,13 +190,25 @@ /** | ||
getCurrentSource: function (options) { | ||
var source_method = options.current_source || options.source; | ||
var source_method = options.source || options.current_source; | ||
var path = window.location.pathname; | ||
if (path == '/') path = '/index'; | ||
// current_source can be a function, hash or a string | ||
if (source_method) { | ||
if (utils.isString(source_method)) | ||
if (utils.isString(source_method)) { | ||
return source_method; | ||
} | ||
if (utils.isFunction(source_method)) | ||
return source_method(); | ||
if (utils.isFunction(source_method)) { | ||
return source_method(path); | ||
} | ||
// TODO: handle the hash method - for dynamic mapping using regular expressions | ||
if (utils.isObject(source_method)) { | ||
for (var exp in source_method) { | ||
var re = new RegExp(exp); | ||
if (path.match(re)) | ||
return source_method[exp]; | ||
} | ||
return path; | ||
} | ||
} | ||
@@ -203,0 +215,0 @@ |
@@ -141,2 +141,6 @@ /** | ||
options.current_source = helpers.getCurrentSource(options); | ||
options.current_locale = helpers.getCurrentLocale(options); | ||
options.current_translator = cookie.translator ? new tml.Translator(cookie.translator) : null; | ||
// updating options and configuring the SDK | ||
@@ -147,12 +151,2 @@ options = tml.utils.merge(tml.config, { | ||
// current source can be a method, a hash or a string | ||
current_source: helpers.getCurrentSource(options), | ||
// for backwards compatibility we support current_locale - but we should switch documentation | ||
// to user "locale" instead. "locale" now supports strategies | ||
current_locale: helpers.getCurrentLocale(options), | ||
// translator information can only be extracted from the cookie | ||
current_translator: cookie.translator ? new tml.Translator(cookie.translator) : null, | ||
// get the list of locales from the browser | ||
@@ -223,2 +217,3 @@ accepted_locales: helpers.getBrowserLanguages(), | ||
domains: options.agent.domains || {}, | ||
tools: options.agent.tools || {}, | ||
locale_strategy: options.locale, | ||
@@ -225,0 +220,0 @@ config: tml.config, |
{ | ||
"name": "tml-js-browser", | ||
"description": "Translation plugin for browsers.", | ||
"version": "0.4.64", | ||
"version": "0.4.65", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Michael Berkovich", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
576459
12879