angular-cn/modules/@angular/compiler/src/i18n/translation_bundle.ts

28 lines
826 B
TypeScript
Raw Normal View History

2016-07-21 13:56:58 -07:00
/**
* @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
*/
import * as html from '../ml_parser/ast';
2016-07-21 13:56:58 -07:00
import {Serializer} from './serializers/serializer';
/**
* A container for translated messages
*/
export class TranslationBundle {
constructor(private _messageMap: {[id: string]: html.Node[]} = {}) {}
static load(
content: string, url: string, placeholders: {[id: string]: {[name: string]: string}},
serializer: Serializer): TranslationBundle {
return new TranslationBundle(serializer.load(content, 'url', placeholders));
}
2016-08-01 14:43:20 -07:00
get(id: string): html.Node[] { return this._messageMap[id]; }
has(id: string): boolean { return id in this._messageMap; }
2016-07-21 13:56:58 -07:00
}