Skip to content

Instantly share code, notes, and snippets.

@vlucas
Created May 31, 2017 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlucas/be96fcf0d8baad7d2a85856696f73536 to your computer and use it in GitHub Desktop.
Save vlucas/be96fcf0d8baad7d2a85856696f73536 to your computer and use it in GitHub Desktop.
// ES5 way
t: function () {
let key = _.first(arguments);
let replacements = _.rest(arguments);
let translation = translations[key];
if (translation && replacements.length) {
translation = format.apply(null, [translation].concat(replacements));
}
return translation || key;
}
// ES6 way
t: function (key, ...replacements) {
let translation = translations[key];
if (translation && replacements.length) {
translation = format.apply(null, [translation].concat(replacements));
}
return translation || key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment