test(ivy): add bundling test todo_i18n (#27420)

PR Close #27420
This commit is contained in:
Olivier Combe
2018-12-03 16:34:25 +01:00
committed by Igor Minar
parent bd864fb274
commit 7f17c70fd0
13 changed files with 996 additions and 6 deletions

View File

@ -13,11 +13,14 @@
* running outside of Closure Compiler. This method will not be needed once runtime translation
* service support is introduced.
*/
export function polyfillGoogGetMsg(): void {
export function polyfillGoogGetMsg(translations: {[key: string]: string} = {}): void {
const glob = (global as any);
glob.goog = glob.goog || {};
glob.goog.getMsg =
glob.goog.getMsg || function(input: string, placeholders: {[key: string]: string} = {}) {
if (typeof translations[input] !== 'undefined') { // to account for empty string
input = translations[input];
}
return Object.keys(placeholders).length ?
input.replace(/\{\$(.*?)\}/g, (match, key) => placeholders[key] || '') :
input;