2016-06-08 23:38:52 +00:00
|
|
|
import {escape, isPresent} from '../facade/lang';
|
|
|
|
|
|
2016-03-14 18:45:14 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A message extracted from a template.
|
|
|
|
|
*
|
|
|
|
|
* The identity of a message is comprised of `content` and `meaning`.
|
|
|
|
|
*
|
|
|
|
|
* `description` is additional information provided to the translator.
|
|
|
|
|
*/
|
|
|
|
|
export class Message {
|
2016-03-23 20:44:45 +00:00
|
|
|
constructor(public content: string, public meaning: string, public description: string = null) {}
|
2016-03-14 18:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Computes the id of a message
|
|
|
|
|
*/
|
|
|
|
|
export function id(m: Message): string {
|
2016-06-08 23:38:52 +00:00
|
|
|
let meaning = isPresent(m.meaning) ? m.meaning : '';
|
|
|
|
|
let content = isPresent(m.content) ? m.content : '';
|
2016-03-14 18:45:14 +00:00
|
|
|
return escape(`$ng|${meaning}|${content}`);
|
2016-04-29 00:50:03 +00:00
|
|
|
}
|