Created
September 1, 2021 14:28
-
-
Save ArtemAvramenko/c5582ac928906b97abb8496fa740822e to your computer and use it in GitHub Desktop.
Angular $localize stub
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
function $localize(s: TemplateStringsArray) { | |
if (s.raw[0][0] === ':') { | |
const i = s[0].indexOf(':', 1) | |
if (i > 0) { | |
return s[0].substring(i + 1); | |
} | |
} | |
return s[0]; | |
} | |
console.log($localize`:meaning|description@@id:source message text`) | |
console.log($localize`:meaning|:source message text`); | |
console.log($localize`:description:source message text`); | |
console.log($localize`:@@id:source message text`); | |
console.log($localize`:@@id:source message text`); | |
console.log($localize`:some description::this message starts with a colon (:)`); | |
console.log($localize`\:this message starts with a colon (:)`); | |
console.log($localize`word\nwrap`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment