Last active
May 14, 2018 12:07
-
-
Save Elendev/1d159d1cf6ff493ddafbf581f71e75f5 to your computer and use it in GitHub Desktop.
Medium : Drupal 8, Typescript, React and i18n - Drupal.t.js
This file contains hidden or 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
| Drupal.t = function (str, args, options) { | |
| options = options || {}; | |
| options.context = options.context || ''; | |
| if (typeof drupalTranslations !== 'undefined' && drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str]) { | |
| str = drupalTranslations.strings[options.context][str]; | |
| } | |
| if (args) { | |
| str = Drupal.formatString(str, args); | |
| } | |
| return str; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment