@angular/compiler
Advanced tools
Comparing version 4.0.0-beta.4 to 4.0.0-beta.5
/** | ||
* @license Angular v4.0.0-beta.4 | ||
* @license Angular v4.0.0-beta.5 | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
@@ -4,0 +4,0 @@ * License: MIT |
@@ -45,3 +45,3 @@ /** | ||
export { ElementSchemaRegistry } from './src/schema/element_schema_registry'; | ||
export { Extractor, I18NHtmlParser, MessageBundle, Xliff, Xmb, Xtb } from './src/i18n/index'; | ||
export { Extractor, I18NHtmlParser, MessageBundle, Serializer, Xliff, Xmb, Xtb } from './src/i18n/index'; | ||
export { DirectiveNormalizer } from './src/directive_normalizer'; | ||
@@ -48,0 +48,0 @@ export { TokenType, Lexer, Token, EOF, isIdentifier, isQuote } from './src/expression_parser/lexer'; |
{ | ||
"name": "@angular/compiler", | ||
"version": "4.0.0-beta.4", | ||
"version": "4.0.0-beta.5", | ||
"description": "Angular - the compiler library", | ||
@@ -11,3 +11,3 @@ "main": "bundles/compiler.umd.js", | ||
"peerDependencies": { | ||
"@angular/core": "4.0.0-beta.4" | ||
"@angular/core": "4.0.0-beta.5" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -9,2 +9,5 @@ | ||
*/ | ||
/** | ||
* Convenience to throw an Error with 'unimplemented' as the message. | ||
*/ | ||
export declare function unimplemented(): any; | ||
@@ -11,0 +14,0 @@ /** |
@@ -7,7 +7,3 @@ var __extends = (this && this.__extends) || function (d, b) { | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* Convenience to throw an Error with 'unimplemented' as the message. | ||
* @return {?} | ||
@@ -14,0 +10,0 @@ */ |
@@ -25,5 +25,8 @@ /** | ||
export function decimalDigest(message) { | ||
if (message.id) { | ||
return message.id; | ||
} | ||
var /** @type {?} */ visitor = new _SerializerIgnoreIcuExpVisitor(); | ||
var /** @type {?} */ parts = message.nodes.map(function (a) { return a.visit(visitor, null); }); | ||
return message.id || computeMsgId(parts.join(''), message.meaning); | ||
return computeMsgId(parts.join(''), message.meaning); | ||
} | ||
@@ -30,0 +33,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"id"},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"sha1"},"arguments":[{"__symbolic":"binop","operator":"+","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"serializeNodes"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"nodes"}]},"member":"join"},"arguments":[""]},"right":{"__symbolic":"error","message":"Expression form not supported","line":11,"character":69}}]}}},"decimalDigest":{"__symbolic":"function"},"serializeNodes":{"__symbolic":"function","parameters":["nodes"],"value":{"__symbolic":"error","message":"Function call not supported","line":58,"character":19}},"sha1":{"__symbolic":"function"},"fingerprint":{"__symbolic":"function"},"computeMsgId":{"__symbolic":"function"}}},{"__symbolic":"module","version":1,"metadata":{"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"id"},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"sha1"},"arguments":[{"__symbolic":"binop","operator":"+","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"serializeNodes"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"nodes"}]},"member":"join"},"arguments":[""]},"right":{"__symbolic":"error","message":"Expression form not supported","line":11,"character":69}}]}}},"decimalDigest":{"__symbolic":"function"},"serializeNodes":{"__symbolic":"function","parameters":["nodes"],"value":{"__symbolic":"error","message":"Function call not supported","line":58,"character":19}},"sha1":{"__symbolic":"function"},"fingerprint":{"__symbolic":"function"},"computeMsgId":{"__symbolic":"function"}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"id"},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"sha1"},"arguments":[{"__symbolic":"binop","operator":"+","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"serializeNodes"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"nodes"}]},"member":"join"},"arguments":[""]},"right":{"__symbolic":"error","message":"Expression form not supported","line":11,"character":69}}]}}},"decimalDigest":{"__symbolic":"function"},"serializeNodes":{"__symbolic":"function","parameters":["nodes"],"value":{"__symbolic":"error","message":"Function call not supported","line":62,"character":19}},"sha1":{"__symbolic":"function"},"fingerprint":{"__symbolic":"function"},"computeMsgId":{"__symbolic":"function"}}},{"__symbolic":"module","version":1,"metadata":{"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"id"},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"sha1"},"arguments":[{"__symbolic":"binop","operator":"+","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"serializeNodes"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"message"},"member":"nodes"}]},"member":"join"},"arguments":[""]},"right":{"__symbolic":"error","message":"Expression form not supported","line":11,"character":69}}]}}},"decimalDigest":{"__symbolic":"function"},"serializeNodes":{"__symbolic":"function","parameters":["nodes"],"value":{"__symbolic":"error","message":"Function call not supported","line":62,"character":19}},"sha1":{"__symbolic":"function"},"fingerprint":{"__symbolic":"function"},"computeMsgId":{"__symbolic":"function"}}}] |
@@ -47,3 +47,3 @@ /** | ||
var /** @type {?} */ programSymbols = extractProgramSymbols(this.staticSymbolResolver, rootFiles, this.host); | ||
var _a = analyzeAndValidateNgModules(programSymbols, this.host, this.metadataResolver), ngModuleByPipeOrDirective = _a.ngModuleByPipeOrDirective, files = _a.files, ngModules = _a.ngModules; | ||
var _a = analyzeAndValidateNgModules(programSymbols, this.host, this.metadataResolver), files = _a.files, ngModules = _a.ngModules; | ||
return Promise | ||
@@ -50,0 +50,0 @@ .all(ngModules.map(function (ngModule) { return _this.metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false); })) |
@@ -100,1 +100,17 @@ /** | ||
} | ||
export declare class CloneVisitor implements Visitor { | ||
visitText(text: Text, context?: any): Text; | ||
visitContainer(container: Container, context?: any): Container; | ||
visitIcu(icu: Icu, context?: any): Icu; | ||
visitTagPlaceholder(ph: TagPlaceholder, context?: any): TagPlaceholder; | ||
visitPlaceholder(ph: Placeholder, context?: any): Placeholder; | ||
visitIcuPlaceholder(ph: IcuPlaceholder, context?: any): IcuPlaceholder; | ||
} | ||
export declare class RecurseVisitor implements Visitor { | ||
visitText(text: Text, context?: any): any; | ||
visitContainer(container: Container, context?: any): any; | ||
visitIcu(icu: Icu, context?: any): any; | ||
visitTagPlaceholder(ph: TagPlaceholder, context?: any): any; | ||
visitPlaceholder(ph: Placeholder, context?: any): any; | ||
visitIcuPlaceholder(ph: IcuPlaceholder, context?: any): any; | ||
} |
@@ -217,2 +217,115 @@ /** | ||
} | ||
export var CloneVisitor = (function () { | ||
function CloneVisitor() { | ||
} | ||
/** | ||
* @param {?} text | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
CloneVisitor.prototype.visitText = function (text, context) { return new Text(text.value, text.sourceSpan); }; | ||
/** | ||
* @param {?} container | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
CloneVisitor.prototype.visitContainer = function (container, context) { | ||
var _this = this; | ||
var /** @type {?} */ children = container.children.map(function (n) { return n.visit(_this, context); }); | ||
return new Container(children, container.sourceSpan); | ||
}; | ||
/** | ||
* @param {?} icu | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
CloneVisitor.prototype.visitIcu = function (icu, context) { | ||
var _this = this; | ||
var /** @type {?} */ cases = {}; | ||
Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); }); | ||
var /** @type {?} */ msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan); | ||
msg.expressionPlaceholder = icu.expressionPlaceholder; | ||
return msg; | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
CloneVisitor.prototype.visitTagPlaceholder = function (ph, context) { | ||
var _this = this; | ||
var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, context); }); | ||
return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
CloneVisitor.prototype.visitPlaceholder = function (ph, context) { | ||
return new Placeholder(ph.value, ph.name, ph.sourceSpan); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
CloneVisitor.prototype.visitIcuPlaceholder = function (ph, context) { | ||
return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan); | ||
}; | ||
return CloneVisitor; | ||
}()); | ||
export var RecurseVisitor = (function () { | ||
function RecurseVisitor() { | ||
} | ||
/** | ||
* @param {?} text | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
RecurseVisitor.prototype.visitText = function (text, context) { }; | ||
; | ||
/** | ||
* @param {?} container | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
RecurseVisitor.prototype.visitContainer = function (container, context) { | ||
var _this = this; | ||
container.children.forEach(function (child) { return child.visit(_this); }); | ||
}; | ||
/** | ||
* @param {?} icu | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
RecurseVisitor.prototype.visitIcu = function (icu, context) { | ||
var _this = this; | ||
Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); }); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
RecurseVisitor.prototype.visitTagPlaceholder = function (ph, context) { | ||
var _this = this; | ||
ph.children.forEach(function (child) { return child.visit(_this); }); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
RecurseVisitor.prototype.visitPlaceholder = function (ph, context) { }; | ||
; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
RecurseVisitor.prototype.visitIcuPlaceholder = function (ph, context) { }; | ||
; | ||
return RecurseVisitor; | ||
}()); | ||
//# sourceMappingURL=i18n_ast.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"Message":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":20,"character":20,"context":{"typeName":"Node"}}]},{"__symbolic":"error","message":"Expression form not supported","line":20,"character":49},{"__symbolic":"error","message":"Expression form not supported","line":21,"character":35},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}},"Text":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Container":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":38,"character":31,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Icu":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":46,"character":68},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"TagPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":54,"character":40},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":55,"character":49,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","name":"boolean"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Placeholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"IcuPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Icu"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Message":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":20,"character":20,"context":{"typeName":"Node"}}]},{"__symbolic":"error","message":"Expression form not supported","line":20,"character":49},{"__symbolic":"error","message":"Expression form not supported","line":21,"character":35},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}},"Text":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Container":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":38,"character":31,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Icu":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":46,"character":68},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"TagPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":54,"character":40},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":55,"character":49,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","name":"boolean"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Placeholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"IcuPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Icu"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"Message":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":20,"character":20,"context":{"typeName":"Node"}}]},{"__symbolic":"error","message":"Expression form not supported","line":20,"character":49},{"__symbolic":"error","message":"Expression form not supported","line":21,"character":35},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}},"Text":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Container":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":38,"character":31,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Icu":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":46,"character":68},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"TagPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":54,"character":40},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":55,"character":49,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","name":"boolean"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Placeholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"IcuPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Icu"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"CloneVisitor":{"__symbolic":"class","members":{"visitText":[{"__symbolic":"method"}],"visitContainer":[{"__symbolic":"method"}],"visitIcu":[{"__symbolic":"method"}],"visitTagPlaceholder":[{"__symbolic":"method"}],"visitPlaceholder":[{"__symbolic":"method"}],"visitIcuPlaceholder":[{"__symbolic":"method"}]}},"RecurseVisitor":{"__symbolic":"class","members":{"visitText":[{"__symbolic":"method"}],"visitContainer":[{"__symbolic":"method"}],"visitIcu":[{"__symbolic":"method"}],"visitTagPlaceholder":[{"__symbolic":"method"}],"visitPlaceholder":[{"__symbolic":"method"}],"visitIcuPlaceholder":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Message":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":20,"character":20,"context":{"typeName":"Node"}}]},{"__symbolic":"error","message":"Expression form not supported","line":20,"character":49},{"__symbolic":"error","message":"Expression form not supported","line":21,"character":35},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}},"Text":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Container":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":38,"character":31,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Icu":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":46,"character":68},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"TagPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"error","message":"Expression form not supported","line":54,"character":40},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":55,"character":49,"context":{"typeName":"Node"}}]},{"__symbolic":"reference","name":"boolean"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"Placeholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"IcuPlaceholder":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Icu"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../parse_util","name":"ParseSourceSpan"}]}],"visit":[{"__symbolic":"method"}]}},"CloneVisitor":{"__symbolic":"class","members":{"visitText":[{"__symbolic":"method"}],"visitContainer":[{"__symbolic":"method"}],"visitIcu":[{"__symbolic":"method"}],"visitTagPlaceholder":[{"__symbolic":"method"}],"visitPlaceholder":[{"__symbolic":"method"}],"visitIcuPlaceholder":[{"__symbolic":"method"}]}},"RecurseVisitor":{"__symbolic":"class","members":{"visitText":[{"__symbolic":"method"}],"visitContainer":[{"__symbolic":"method"}],"visitIcu":[{"__symbolic":"method"}],"visitTagPlaceholder":[{"__symbolic":"method"}],"visitPlaceholder":[{"__symbolic":"method"}],"visitIcuPlaceholder":[{"__symbolic":"method"}]}}}}] |
@@ -11,2 +11,3 @@ /** | ||
export { MessageBundle } from './message_bundle'; | ||
export { Serializer } from './serializers/serializer'; | ||
export { Xliff } from './serializers/xliff'; | ||
@@ -13,0 +14,0 @@ export { Xmb } from './serializers/xmb'; |
@@ -11,3 +11,3 @@ /** | ||
import { ParseError } from '../parse_util'; | ||
import { Message } from './i18n_ast'; | ||
import * as i18n from './i18n_ast'; | ||
import { Serializer } from './serializers/serializer'; | ||
@@ -26,4 +26,4 @@ /** | ||
updateFromTemplate(html: string, url: string, interpolationConfig: InterpolationConfig): ParseError[]; | ||
getMessages(): Message[]; | ||
getMessages(): i18n.Message[]; | ||
write(serializer: Serializer): string; | ||
} |
@@ -8,3 +8,9 @@ /** | ||
*/ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
import { extractMessages } from './extractor_merger'; | ||
import * as i18n from './i18n_ast'; | ||
/** | ||
@@ -51,3 +57,21 @@ * A container for message extracted from the templates. | ||
*/ | ||
MessageBundle.prototype.write = function (serializer) { return serializer.write(this._messages); }; | ||
MessageBundle.prototype.write = function (serializer) { | ||
var /** @type {?} */ messages = {}; | ||
var /** @type {?} */ mapperVisitor = new MapPlaceholderNames(); | ||
// Deduplicate messages based on their ID | ||
this._messages.forEach(function (message) { | ||
var /** @type {?} */ id = serializer.digest(message); | ||
if (!messages.hasOwnProperty(id)) { | ||
messages[id] = message; | ||
} | ||
}); | ||
// Transform placeholder names using the serializer mapping | ||
var /** @type {?} */ msgList = Object.keys(messages).map(function (id) { | ||
var /** @type {?} */ mapper = serializer.createNameMapper(messages[id]); | ||
var /** @type {?} */ src = messages[id]; | ||
var /** @type {?} */ nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes; | ||
return new i18n.Message(nodes, {}, {}, src.meaning, src.description, id); | ||
}); | ||
return serializer.write(msgList); | ||
}; | ||
return MessageBundle; | ||
@@ -65,2 +89,46 @@ }()); | ||
} | ||
var MapPlaceholderNames = (function (_super) { | ||
__extends(MapPlaceholderNames, _super); | ||
function MapPlaceholderNames() { | ||
_super.apply(this, arguments); | ||
} | ||
/** | ||
* @param {?} nodes | ||
* @param {?} mapper | ||
* @return {?} | ||
*/ | ||
MapPlaceholderNames.prototype.convert = function (nodes, mapper) { | ||
var _this = this; | ||
return mapper ? nodes.map(function (n) { return n.visit(_this, mapper); }) : nodes; | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?} mapper | ||
* @return {?} | ||
*/ | ||
MapPlaceholderNames.prototype.visitTagPlaceholder = function (ph, mapper) { | ||
var _this = this; | ||
var /** @type {?} */ startName = mapper.toPublicName(ph.startName); | ||
var /** @type {?} */ closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName; | ||
var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, mapper); }); | ||
return new i18n.TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?} mapper | ||
* @return {?} | ||
*/ | ||
MapPlaceholderNames.prototype.visitPlaceholder = function (ph, mapper) { | ||
return new i18n.Placeholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?} mapper | ||
* @return {?} | ||
*/ | ||
MapPlaceholderNames.prototype.visitIcuPlaceholder = function (ph, mapper) { | ||
return new i18n.IcuPlaceholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan); | ||
}; | ||
return MapPlaceholderNames; | ||
}(i18n.CloneVisitor)); | ||
//# sourceMappingURL=message_bundle.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"MessageBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../ml_parser/html_parser","name":"HtmlParser"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"string"}]},{"__symbolic":"error","message":"Expression form not supported","line":24,"character":30}]}],"updateFromTemplate":[{"__symbolic":"method"}],"getMessages":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"MessageBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../ml_parser/html_parser","name":"HtmlParser"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"string"}]},{"__symbolic":"error","message":"Expression form not supported","line":24,"character":30}]}],"updateFromTemplate":[{"__symbolic":"method"}],"getMessages":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"MessageBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../ml_parser/html_parser","name":"HtmlParser"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"string"}]},{"__symbolic":"error","message":"Expression form not supported","line":25,"character":30}]}],"updateFromTemplate":[{"__symbolic":"method"}],"getMessages":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"MessageBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../ml_parser/html_parser","name":"HtmlParser"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"string"}]},{"__symbolic":"error","message":"Expression form not supported","line":25,"character":30}]}],"updateFromTemplate":[{"__symbolic":"method"}],"getMessages":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}]}}}}] |
@@ -128,5 +128,10 @@ /** | ||
PlaceholderRegistry.prototype._generateUniqueName = function (base) { | ||
var /** @type {?} */ next = this._placeHolderNameCounts[base]; | ||
this._placeHolderNameCounts[base] = next ? next + 1 : 1; | ||
return next ? base + "_" + next : base; | ||
var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base); | ||
if (!seen) { | ||
this._placeHolderNameCounts[base] = 1; | ||
return base; | ||
} | ||
var /** @type {?} */ id = this._placeHolderNameCounts[base]; | ||
this._placeHolderNameCounts[base] = id + 1; | ||
return base + "_" + id; | ||
}; | ||
@@ -133,0 +138,0 @@ return PlaceholderRegistry; |
@@ -9,8 +9,36 @@ /** | ||
import * as i18n from '../i18n_ast'; | ||
export interface Serializer { | ||
write(messages: i18n.Message[]): string; | ||
load(content: string, url: string): { | ||
export declare abstract class Serializer { | ||
abstract write(messages: i18n.Message[]): string; | ||
abstract load(content: string, url: string): { | ||
[msgId: string]: i18n.Node[]; | ||
}; | ||
digest(message: i18n.Message): string; | ||
abstract digest(message: i18n.Message): string; | ||
createNameMapper(message: i18n.Message): PlaceholderMapper; | ||
} | ||
/** | ||
* A `PlaceholderMapper` converts placeholder names from internal to serialized representation and | ||
* back. | ||
* | ||
* It should be used for serialization format that put constraints on the placeholder names. | ||
*/ | ||
export interface PlaceholderMapper { | ||
toPublicName(internalName: string): string; | ||
toInternalName(publicName: string): string; | ||
} | ||
/** | ||
* A simple mapper that take a function to transform an internal name to a public name | ||
*/ | ||
export declare class SimplePlaceholderMapper extends i18n.RecurseVisitor implements PlaceholderMapper { | ||
private mapName; | ||
private internalToPublic; | ||
private publicToNextId; | ||
private publicToInternal; | ||
constructor(message: i18n.Message, mapName: (name: string) => string); | ||
toPublicName(internalName: string): string; | ||
toInternalName(publicName: string): string; | ||
visitText(text: i18n.Text, context?: any): any; | ||
visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): any; | ||
visitPlaceholder(ph: i18n.Placeholder, context?: any): any; | ||
visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any; | ||
private visitPlaceholderName(internalName); | ||
} |
@@ -8,2 +8,138 @@ /** | ||
*/ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
import * as i18n from '../i18n_ast'; | ||
/** | ||
* @abstract | ||
*/ | ||
export var Serializer = (function () { | ||
function Serializer() { | ||
} | ||
/** | ||
* @abstract | ||
* @param {?} messages | ||
* @return {?} | ||
*/ | ||
Serializer.prototype.write = function (messages) { }; | ||
/** | ||
* @abstract | ||
* @param {?} content | ||
* @param {?} url | ||
* @return {?} | ||
*/ | ||
Serializer.prototype.load = function (content, url) { }; | ||
/** | ||
* @abstract | ||
* @param {?} message | ||
* @return {?} | ||
*/ | ||
Serializer.prototype.digest = function (message) { }; | ||
/** | ||
* @param {?} message | ||
* @return {?} | ||
*/ | ||
Serializer.prototype.createNameMapper = function (message) { return null; }; | ||
return Serializer; | ||
}()); | ||
/** | ||
* A simple mapper that take a function to transform an internal name to a public name | ||
*/ | ||
export var SimplePlaceholderMapper = (function (_super) { | ||
__extends(SimplePlaceholderMapper, _super); | ||
/** | ||
* @param {?} message | ||
* @param {?} mapName | ||
*/ | ||
function SimplePlaceholderMapper(message, mapName) { | ||
var _this = this; | ||
_super.call(this); | ||
this.mapName = mapName; | ||
this.internalToPublic = {}; | ||
this.publicToNextId = {}; | ||
this.publicToInternal = {}; | ||
message.nodes.forEach(function (node) { return node.visit(_this); }); | ||
} | ||
/** | ||
* @param {?} internalName | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.toPublicName = function (internalName) { | ||
return this.internalToPublic.hasOwnProperty(internalName) ? | ||
this.internalToPublic[internalName] : | ||
null; | ||
}; | ||
/** | ||
* @param {?} publicName | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.toInternalName = function (publicName) { | ||
return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] : | ||
null; | ||
}; | ||
/** | ||
* @param {?} text | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.visitText = function (text, context) { return null; }; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.visitTagPlaceholder = function (ph, context) { | ||
this.visitPlaceholderName(ph.startName); | ||
_super.prototype.visitTagPlaceholder.call(this, ph, context); | ||
this.visitPlaceholderName(ph.closeName); | ||
}; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.visitPlaceholder = function (ph, context) { this.visitPlaceholderName(ph.name); }; | ||
/** | ||
* @param {?} ph | ||
* @param {?=} context | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.visitIcuPlaceholder = function (ph, context) { | ||
this.visitPlaceholderName(ph.name); | ||
}; | ||
/** | ||
* @param {?} internalName | ||
* @return {?} | ||
*/ | ||
SimplePlaceholderMapper.prototype.visitPlaceholderName = function (internalName) { | ||
if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) { | ||
return; | ||
} | ||
var /** @type {?} */ publicName = this.mapName(internalName); | ||
if (this.publicToInternal.hasOwnProperty(publicName)) { | ||
// Create a new XMB when it has already been used | ||
var /** @type {?} */ nextId = this.publicToNextId[publicName]; | ||
this.publicToNextId[publicName] = nextId + 1; | ||
publicName = publicName + "_" + nextId; | ||
} | ||
else { | ||
this.publicToNextId[publicName] = 1; | ||
} | ||
this.internalToPublic[internalName] = publicName; | ||
this.publicToInternal[publicName] = internalName; | ||
}; | ||
return SimplePlaceholderMapper; | ||
}(i18n.RecurseVisitor)); | ||
function SimplePlaceholderMapper_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
SimplePlaceholderMapper.prototype.internalToPublic; | ||
/** @type {?} */ | ||
SimplePlaceholderMapper.prototype.publicToNextId; | ||
/** @type {?} */ | ||
SimplePlaceholderMapper.prototype.publicToInternal; | ||
/** @type {?} */ | ||
SimplePlaceholderMapper.prototype.mapName; | ||
} | ||
//# sourceMappingURL=serializer.js.map |
import * as i18n from '../i18n_ast'; | ||
import { Serializer } from './serializer'; | ||
export declare class Xliff implements Serializer { | ||
export declare class Xliff extends Serializer { | ||
write(messages: i18n.Message[]): string; | ||
@@ -5,0 +5,0 @@ load(content: string, url: string): { |
@@ -8,2 +8,7 @@ /** | ||
*/ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
import * as ml from '../../ml_parser/ast'; | ||
@@ -14,2 +19,3 @@ import { XmlParser } from '../../ml_parser/xml_parser'; | ||
import { I18nError } from '../parse_util'; | ||
import { Serializer } from './serializer'; | ||
import * as xml from './xml_helper'; | ||
@@ -24,4 +30,6 @@ var /** @type {?} */ _VERSION = '1.2'; | ||
var /** @type {?} */ _UNIT_TAG = 'trans-unit'; | ||
export var Xliff = (function () { | ||
export var Xliff = (function (_super) { | ||
__extends(Xliff, _super); | ||
function Xliff() { | ||
_super.apply(this, arguments); | ||
} | ||
@@ -33,13 +41,6 @@ /** | ||
Xliff.prototype.write = function (messages) { | ||
var _this = this; | ||
var /** @type {?} */ visitor = new _WriteVisitor(); | ||
var /** @type {?} */ visited = {}; | ||
var /** @type {?} */ transUnits = []; | ||
messages.forEach(function (message) { | ||
var /** @type {?} */ id = _this.digest(message); | ||
// deduplicate messages | ||
if (visited[id]) | ||
return; | ||
visited[id] = true; | ||
var /** @type {?} */ transUnit = new xml.Tag(_UNIT_TAG, { id: id, datatype: 'html' }); | ||
var /** @type {?} */ transUnit = new xml.Tag(_UNIT_TAG, { id: message.id, datatype: 'html' }); | ||
transUnit.children.push(new xml.CR(8), new xml.Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes)), new xml.CR(8), new xml.Tag(_TARGET_TAG)); | ||
@@ -90,3 +91,3 @@ if (message.description) { | ||
return Xliff; | ||
}()); | ||
}(Serializer)); | ||
var _WriteVisitor = (function () { | ||
@@ -93,0 +94,0 @@ function _WriteVisitor() { |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"Xliff":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xliff":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"Xliff":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xliff":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}}] |
import * as i18n from '../i18n_ast'; | ||
import { Serializer } from './serializer'; | ||
export declare class Xmb implements Serializer { | ||
import { PlaceholderMapper, Serializer } from './serializer'; | ||
export declare class Xmb extends Serializer { | ||
write(messages: i18n.Message[]): string; | ||
@@ -9,3 +9,5 @@ load(content: string, url: string): { | ||
digest(message: i18n.Message): string; | ||
createNameMapper(message: i18n.Message): PlaceholderMapper; | ||
} | ||
export declare function digest(message: i18n.Message): string; | ||
export declare function toPublicName(internalName: string): string; |
@@ -8,3 +8,9 @@ /** | ||
*/ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
import { decimalDigest } from '../digest'; | ||
import { Serializer, SimplePlaceholderMapper } from './serializer'; | ||
import * as xml from './xml_helper'; | ||
@@ -16,4 +22,6 @@ var /** @type {?} */ _MESSAGES_TAG = 'messagebundle'; | ||
var /** @type {?} */ _DOCTYPE = "<!ELEMENT messagebundle (msg)*>\n<!ATTLIST messagebundle class CDATA #IMPLIED>\n\n<!ELEMENT msg (#PCDATA|ph|source)*>\n<!ATTLIST msg id CDATA #IMPLIED>\n<!ATTLIST msg seq CDATA #IMPLIED>\n<!ATTLIST msg name CDATA #IMPLIED>\n<!ATTLIST msg desc CDATA #IMPLIED>\n<!ATTLIST msg meaning CDATA #IMPLIED>\n<!ATTLIST msg obsolete (obsolete) #IMPLIED>\n<!ATTLIST msg xml:space (default|preserve) \"default\">\n<!ATTLIST msg is_hidden CDATA #IMPLIED>\n\n<!ELEMENT source (#PCDATA)>\n\n<!ELEMENT ph (#PCDATA|ex)*>\n<!ATTLIST ph name CDATA #REQUIRED>\n\n<!ELEMENT ex (#PCDATA)>"; | ||
export var Xmb = (function () { | ||
export var Xmb = (function (_super) { | ||
__extends(Xmb, _super); | ||
function Xmb() { | ||
_super.apply(this, arguments); | ||
} | ||
@@ -25,14 +33,7 @@ /** | ||
Xmb.prototype.write = function (messages) { | ||
var _this = this; | ||
var /** @type {?} */ exampleVisitor = new ExampleVisitor(); | ||
var /** @type {?} */ visitor = new _Visitor(); | ||
var /** @type {?} */ visited = {}; | ||
var /** @type {?} */ rootNode = new xml.Tag(_MESSAGES_TAG); | ||
messages.forEach(function (message) { | ||
var /** @type {?} */ id = _this.digest(message); | ||
// deduplicate messages | ||
if (visited[id]) | ||
return; | ||
visited[id] = true; | ||
var /** @type {?} */ attrs = { id: id }; | ||
var /** @type {?} */ attrs = { id: message.id }; | ||
if (message.description) { | ||
@@ -69,4 +70,11 @@ attrs['desc'] = message.description; | ||
Xmb.prototype.digest = function (message) { return digest(message); }; | ||
/** | ||
* @param {?} message | ||
* @return {?} | ||
*/ | ||
Xmb.prototype.createNameMapper = function (message) { | ||
return new SimplePlaceholderMapper(message, toPublicName); | ||
}; | ||
return Xmb; | ||
}()); | ||
}(Serializer)); | ||
var _Visitor = (function () { | ||
@@ -83,3 +91,3 @@ function _Visitor() { | ||
* @param {?} container | ||
* @param {?=} context | ||
* @param {?} context | ||
* @return {?} | ||
@@ -201,2 +209,9 @@ */ | ||
}()); | ||
/** | ||
* @param {?} internalName | ||
* @return {?} | ||
*/ | ||
export function toPublicName(internalName) { | ||
return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_'); | ||
} | ||
//# sourceMappingURL=xmb.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"Xmb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xmb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"Xmb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}},"toPublicName":{"__symbolic":"function","parameters":["internalName"],"value":{"__symbolic":"error","message":"Expression form not supported","line":161,"character":44}}}},{"__symbolic":"module","version":1,"metadata":{"Xmb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}},"toPublicName":{"__symbolic":"function","parameters":["internalName"],"value":{"__symbolic":"error","message":"Expression form not supported","line":161,"character":44}}}}] |
import * as i18n from '../i18n_ast'; | ||
import { Serializer } from './serializer'; | ||
export declare class Xtb implements Serializer { | ||
import { PlaceholderMapper, Serializer } from './serializer'; | ||
export declare class Xtb extends Serializer { | ||
write(messages: i18n.Message[]): string; | ||
@@ -9,2 +9,3 @@ load(content: string, url: string): { | ||
digest(message: i18n.Message): string; | ||
createNameMapper(message: i18n.Message): PlaceholderMapper; | ||
} |
@@ -8,2 +8,7 @@ /** | ||
*/ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
import * as ml from '../../ml_parser/ast'; | ||
@@ -13,8 +18,11 @@ import { XmlParser } from '../../ml_parser/xml_parser'; | ||
import { I18nError } from '../parse_util'; | ||
import { digest } from './xmb'; | ||
import { Serializer, SimplePlaceholderMapper } from './serializer'; | ||
import { digest, toPublicName } from './xmb'; | ||
var /** @type {?} */ _TRANSLATIONS_TAG = 'translationbundle'; | ||
var /** @type {?} */ _TRANSLATION_TAG = 'translation'; | ||
var /** @type {?} */ _PLACEHOLDER_TAG = 'ph'; | ||
export var Xtb = (function () { | ||
export var Xtb = (function (_super) { | ||
__extends(Xtb, _super); | ||
function Xtb() { | ||
_super.apply(this, arguments); | ||
} | ||
@@ -53,4 +61,11 @@ /** | ||
Xtb.prototype.digest = function (message) { return digest(message); }; | ||
/** | ||
* @param {?} message | ||
* @return {?} | ||
*/ | ||
Xtb.prototype.createNameMapper = function (message) { | ||
return new SimplePlaceholderMapper(message, toPublicName); | ||
}; | ||
return Xtb; | ||
}()); | ||
}(Serializer)); | ||
var XtbParser = (function () { | ||
@@ -57,0 +72,0 @@ function XtbParser() { |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"Xtb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xtb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"Xtb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xtb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}}}}] |
@@ -10,3 +10,3 @@ /** | ||
import * as i18n from './i18n_ast'; | ||
import { Serializer } from './serializers/serializer'; | ||
import { PlaceholderMapper, Serializer } from './serializers/serializer'; | ||
/** | ||
@@ -18,6 +18,7 @@ * A container for translated messages | ||
digest: (m: i18n.Message) => string; | ||
mapperFactory: (m: i18n.Message) => PlaceholderMapper; | ||
private _i18nToHtml; | ||
constructor(_i18nNodesByMsgId: { | ||
[msgId: string]: i18n.Node[]; | ||
}, digest: (m: i18n.Message) => string); | ||
}, digest: (m: i18n.Message) => string, mapperFactory?: (m: i18n.Message) => PlaceholderMapper); | ||
static load(content: string, url: string, serializer: Serializer): TranslationBundle; | ||
@@ -24,0 +25,0 @@ get(srcMsg: i18n.Message): html.Node[]; |
@@ -17,8 +17,10 @@ /** | ||
* @param {?} digest | ||
* @param {?=} mapperFactory | ||
*/ | ||
function TranslationBundle(_i18nNodesByMsgId, digest) { | ||
function TranslationBundle(_i18nNodesByMsgId, digest, mapperFactory) { | ||
if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; } | ||
this._i18nNodesByMsgId = _i18nNodesByMsgId; | ||
this.digest = digest; | ||
this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, digest); | ||
this.mapperFactory = mapperFactory; | ||
this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, digest, mapperFactory); | ||
} | ||
@@ -34,3 +36,4 @@ /** | ||
var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); }; | ||
return new TranslationBundle(i18nNodesByMsgId, digestFn); | ||
var /** @type {?} */ mapperFactory = function (m) { return serializer.createNameMapper(m); }; | ||
return new TranslationBundle(i18nNodesByMsgId, digestFn, mapperFactory); | ||
}; | ||
@@ -62,2 +65,4 @@ /** | ||
TranslationBundle.prototype.digest; | ||
/** @type {?} */ | ||
TranslationBundle.prototype.mapperFactory; | ||
} | ||
@@ -68,8 +73,10 @@ var I18nToHtmlVisitor = (function () { | ||
* @param {?} _digest | ||
* @param {?} _mapperFactory | ||
*/ | ||
function I18nToHtmlVisitor(_i18nNodesByMsgId, _digest) { | ||
function I18nToHtmlVisitor(_i18nNodesByMsgId, _digest, _mapperFactory) { | ||
if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; } | ||
this._i18nNodesByMsgId = _i18nNodesByMsgId; | ||
this._digest = _digest; | ||
this._srcMsgStack = []; | ||
this._mapperFactory = _mapperFactory; | ||
this._contextStack = []; | ||
this._errors = []; | ||
@@ -82,3 +89,3 @@ } | ||
I18nToHtmlVisitor.prototype.convert = function (srcMsg) { | ||
this._srcMsgStack.length = 0; | ||
this._contextStack.length = 0; | ||
this._errors.length = 0; | ||
@@ -131,3 +138,3 @@ // i18n to text | ||
I18nToHtmlVisitor.prototype.visitPlaceholder = function (ph, context) { | ||
var /** @type {?} */ phName = ph.name; | ||
var /** @type {?} */ phName = this._mapper(ph.name); | ||
if (this._srcMsg.placeholders.hasOwnProperty(phName)) { | ||
@@ -155,2 +162,6 @@ return this._srcMsg.placeholders[phName]; | ||
/** | ||
* Convert a source message to a translated text string: | ||
* - text nodes are replaced with their translation, | ||
* - placeholders are replaced with their content, | ||
* - ICU nodes are converted to ICU expressions. | ||
* @param {?} srcMsg | ||
@@ -162,8 +173,12 @@ * @return {?} | ||
var /** @type {?} */ digest = this._digest(srcMsg); | ||
var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null; | ||
if (this._i18nNodesByMsgId.hasOwnProperty(digest)) { | ||
this._srcMsgStack.push(this._srcMsg); | ||
this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper }); | ||
this._srcMsg = srcMsg; | ||
this._mapper = function (name) { return mapper ? mapper.toInternalName(name) : name; }; | ||
var /** @type {?} */ nodes = this._i18nNodesByMsgId[digest]; | ||
var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join(''); | ||
this._srcMsg = this._srcMsgStack.pop(); | ||
var /** @type {?} */ context = this._contextStack.pop(); | ||
this._srcMsg = context.msg; | ||
this._mapper = context.mapper; | ||
return text; | ||
@@ -188,10 +203,14 @@ } | ||
/** @type {?} */ | ||
I18nToHtmlVisitor.prototype._srcMsgStack; | ||
I18nToHtmlVisitor.prototype._contextStack; | ||
/** @type {?} */ | ||
I18nToHtmlVisitor.prototype._errors; | ||
/** @type {?} */ | ||
I18nToHtmlVisitor.prototype._mapper; | ||
/** @type {?} */ | ||
I18nToHtmlVisitor.prototype._i18nNodesByMsgId; | ||
/** @type {?} */ | ||
I18nToHtmlVisitor.prototype._digest; | ||
/** @type {?} */ | ||
I18nToHtmlVisitor.prototype._mapperFactory; | ||
} | ||
//# sourceMappingURL=translation_bundle.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21},{"__symbolic":"error","message":"Expression form not supported","line":24,"character":29}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21},{"__symbolic":"error","message":"Expression form not supported","line":24,"character":29}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}}] |
@@ -12,3 +12,4 @@ /** | ||
'(?:\\.([-\\w]+))|' + | ||
'(?:\\[([.-\\w*]+)(?:=([^\\]]*))?\\])|' + | ||
// "-" should appear first in the regexp below as FF31 parses "[.-\w]" as a range | ||
'(?:\\[([-.\\w*]+)(?:=([^\\]]*))?\\])|' + | ||
'(\\))|' + | ||
@@ -15,0 +16,0 @@ '(\\s*,\\s*)', // "," |
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
export var /** @type {?} */ VERSION = new Version('4.0.0-beta.4'); | ||
export var /** @type {?} */ VERSION = new Version('4.0.0-beta.5'); | ||
//# sourceMappingURL=version.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["4.0.0-beta.4"]}}},{"__symbolic":"module","version":1,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["4.0.0-beta.4"]}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["4.0.0-beta.5"]}}},{"__symbolic":"module","version":1,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["4.0.0-beta.5"]}}}] |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5823016
484
69558