Created
May 31, 2017 21:07
-
-
Save vlucas/be96fcf0d8baad7d2a85856696f73536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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