Skip to content

Instantly share code, notes, and snippets.

@ArtemAvramenko
Created September 1, 2021 14:28
Show Gist options
  • Save ArtemAvramenko/c5582ac928906b97abb8496fa740822e to your computer and use it in GitHub Desktop.
Save ArtemAvramenko/c5582ac928906b97abb8496fa740822e to your computer and use it in GitHub Desktop.
Angular $localize stub
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