Skip to content

Commit

Permalink
Merge pull request #2 from vtex/feature/starts-with-currency
Browse files Browse the repository at this point in the history
Add starts with currency function
  • Loading branch information
alinealvesvianna committed Sep 20, 2017
2 parents 69c349b + 5f6617c commit 266d08f
Show file tree
Hide file tree
Showing 8 changed files with 4,345 additions and 68 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,5 @@ build/
deploy/
node_modules/
.idea/
bower_components/
bower_components/
.DS_Store
58 changes: 34 additions & 24 deletions dist/vtex-i18n.js
@@ -1,30 +1,32 @@
(function() {
var VtexI18n,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

window.vtex = window.vtex || {};

window.vtex.i18n = window.vtex.i18n || {};

VtexI18n = (function() {
function VtexI18n() {
this.callCountryCodeCallback = __bind(this.callCountryCodeCallback, this);
this.callLocaleCallback = __bind(this.callLocaleCallback, this);
this.translateHtml = __bind(this.translateHtml, this);
this.setDecimalDigits = __bind(this.setDecimalDigits, this);
this.getDecimalDigits = __bind(this.getDecimalDigits, this);
this.setThousandsSeparator = __bind(this.setThousandsSeparator, this);
this.getThousandsSeparator = __bind(this.getThousandsSeparator, this);
this.setDecimalSeparator = __bind(this.setDecimalSeparator, this);
this.getDecimalSeparator = __bind(this.getDecimalSeparator, this);
this.setCurrency = __bind(this.setCurrency, this);
this.getCurrency = __bind(this.getCurrency, this);
this.setCountryCodeCallback = __bind(this.setCountryCodeCallback, this);
this.setCountryCode = __bind(this.setCountryCode, this);
this.getCountryCode = __bind(this.getCountryCode, this);
this.setLocaleCallback = __bind(this.setLocaleCallback, this);
this.setLocale = __bind(this.setLocale, this);
this.getLocale = __bind(this.getLocale, this);
this.callCountryCodeCallback = bind(this.callCountryCodeCallback, this);
this.callLocaleCallback = bind(this.callLocaleCallback, this);
this.translateHtml = bind(this.translateHtml, this);
this.setDecimalDigits = bind(this.setDecimalDigits, this);
this.getDecimalDigits = bind(this.getDecimalDigits, this);
this.setThousandsSeparator = bind(this.setThousandsSeparator, this);
this.getThousandsSeparator = bind(this.getThousandsSeparator, this);
this.setDecimalSeparator = bind(this.setDecimalSeparator, this);
this.getDecimalSeparator = bind(this.getDecimalSeparator, this);
this.setStartsWithCurrency = bind(this.setStartsWithCurrency, this);
this.getStartsWithCurrency = bind(this.getStartsWithCurrency, this);
this.setCurrency = bind(this.setCurrency, this);
this.getCurrency = bind(this.getCurrency, this);
this.setCountryCodeCallback = bind(this.setCountryCodeCallback, this);
this.setCountryCode = bind(this.setCountryCode, this);
this.getCountryCode = bind(this.getCountryCode, this);
this.setLocaleCallback = bind(this.setLocaleCallback, this);
this.setLocale = bind(this.setLocale, this);
this.getLocale = bind(this.getLocale, this);
this.locale = $('html').attr('lang') || $('meta[name="language"]').attr('content') || 'pt-BR';
this.countryCode = $('meta[name="country"]').attr('content') || 'BRA';
this.currency = $('meta[name="currency"]').attr('content');
Expand Down Expand Up @@ -89,6 +91,14 @@
return this.currency = currency;
};

VtexI18n.prototype.getStartsWithCurrency = function(startsWithCurrency) {
return this.startsWithCurrency;
};

VtexI18n.prototype.setStartsWithCurrency = function(startsWithCurrency) {
return this.startsWithCurrency = startsWithCurrency;
};

VtexI18n.prototype.getDecimalSeparator = function(countryCodeParam) {
var countryCode;
if (this.currencyDecimalSeparator) {
Expand Down Expand Up @@ -146,20 +156,20 @@
};

VtexI18n.prototype.translateHtml = function(selector) {
var _base;
var base;
if (selector == null) {
selector = 'html';
}
if (window.i18n) {
return typeof (_base = $(selector)).i18n === "function" ? _base.i18n() : void 0;
return typeof (base = $(selector)).i18n === "function" ? base.i18n() : void 0;
}
};

/*
# Caso o callback seja do tipo function, chama a função
# Caso seja do tipo string assume-se que será chamado um canal do Radio
*/

/*
* Caso o callback seja do tipo function, chama a função
* Caso seja do tipo string assume-se que será chamado um canal do Radio
*/

VtexI18n.prototype.callLocaleCallback = function(val) {
if (typeof this.localeCallback === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion dist/vtex-i18n.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 27 additions & 24 deletions dist/vtex-locale-selector.js
@@ -1,29 +1,30 @@
(function() {
window.vtex.i18n.init = function() {
var localeText,
_this = this;
var localeText;
i18n.init({
customLoad: function(lng, ns, options, loadComplete) {
var dictionary, requireLang, translationFiles, _i, _len, _ref;
if (vtex.i18n.requireLang && vtex.curl) {
translationFiles = [];
_ref = vtex.i18n.requireLang;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
requireLang = _ref[_i];
translationFiles.push(requireLang + lng);
}
return vtex.curl(translationFiles).then(function() {
return loadComplete(null, vtex.i18n[lng]);
});
} else {
dictionary = vtex.i18n[lng];
if (dictionary) {
return loadComplete(null, dictionary);
customLoad: (function(_this) {
return function(lng, ns, options, loadComplete) {
var dictionary, i, len, ref, requireLang, translationFiles;
if (vtex.i18n.requireLang && vtex.curl) {
translationFiles = [];
ref = vtex.i18n.requireLang;
for (i = 0, len = ref.length; i < len; i++) {
requireLang = ref[i];
translationFiles.push(requireLang + lng);
}
return vtex.curl(translationFiles).then(function() {
return loadComplete(null, vtex.i18n[lng]);
});
} else {
return loadComplete(null, vtex.i18n['pt-BR']);
dictionary = vtex.i18n[lng];
if (dictionary) {
return loadComplete(null, dictionary);
} else {
return loadComplete(null, vtex.i18n['pt-BR']);
}
}
}
},
};
})(this),
lng: window.vtex.i18n.getLocale(),
load: 'current',
fallbackLng: 'pt-BR'
Expand All @@ -39,9 +40,11 @@
$('#vtex-locale-select').select2({
placeholder: localeText
});
$('#vtex-locale-select').change(function(e, data) {
return window.vtex.i18n.setLocale(e.val);
});
$('#vtex-locale-select').change((function(_this) {
return function(e, data) {
return window.vtex.i18n.setLocale(e.val);
};
})(this));
}
$('html').i18n();
};
Expand Down
2 changes: 1 addition & 1 deletion dist/vtex-locale-selector.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 266d08f

Please sign in to comment.