Lines Matching refs:pattern

73  * @param {string} pattern The pattern we parse and apply positional parameters
78 goog.i18n.MessageFormat = function(pattern) {
88 * Input pattern gets parsed into objects for faster formatting.
94 this.parsePattern_(pattern);
248 var pattern = parsedPattern[i].value;
249 this.formatSimplePlaceholder_(pattern, namedParameters, result);
252 var pattern = parsedPattern[i].value;
253 this.formatSelectBlock_(pattern, namedParameters, ignorePound, result);
256 var pattern = parsedPattern[i].value;
257 this.formatPluralOrdinalBlock_(pattern,
264 var pattern = parsedPattern[i].value;
265 this.formatPluralOrdinalBlock_(pattern,
394 * Parses input pattern into an array, for faster reformatting with
397 * @param {string} pattern MessageFormat pattern to parse.
400 goog.i18n.MessageFormat.prototype.parsePattern_ = function(pattern) {
401 if (pattern) {
402 pattern = this.insertPlaceholders_(pattern);
404 this.parsedPattern_ = this.parseBlock_(pattern);
414 * @param {string} pattern Pattern to clean up.
418 goog.i18n.MessageFormat.prototype.insertPlaceholders_ = function(pattern) {
424 pattern = pattern.replace(
431 pattern = pattern.replace(
438 return pattern;
443 * Breaks pattern into strings and top level {...} blocks.
444 * @param {string} pattern (sub)Pattern to be broken.
448 goog.i18n.MessageFormat.prototype.extractParts_ = function(pattern) {
458 while (match = braces.exec(pattern)) {
469 part.value = pattern.substring(prevPos, pos);
477 var substring = pattern.substring(prevPos, pos);
492 'There are mismatched { or } in the pattern.');
494 var substring = pattern.substring(prevPos);
535 * Detects which type of a block is the pattern.
536 * @param {string} pattern Content of the block.
540 goog.i18n.MessageFormat.prototype.parseBlockType_ = function(pattern) {
541 if (goog.i18n.MessageFormat.PLURAL_BLOCK_RE_.test(pattern)) {
545 if (goog.i18n.MessageFormat.ORDINAL_BLOCK_RE_.test(pattern)) {
549 if (goog.i18n.MessageFormat.SELECT_BLOCK_RE_.test(pattern)) {
553 if (/^\s*\w+\s*/.test(pattern)) {
563 * @param {string} pattern Content of the block to parse.
567 goog.i18n.MessageFormat.prototype.parseBlock_ = function(pattern) {
569 var parts = this.extractParts_(pattern);
599 goog.asserts.fail('Unknown part of the pattern.');
610 * @param {string} pattern Subpattern that needs to be parsed as select pattern.
614 goog.i18n.MessageFormat.prototype.parseSelectBlock_ = function(pattern) {
617 pattern = pattern.replace(replaceRegex, function(string, name) {
624 var parts = this.extractParts_(pattern);
652 * @param {string} pattern Subpattern that needs to be parsed as plural pattern.
656 goog.i18n.MessageFormat.prototype.parsePluralBlock_ = function(pattern) {
660 pattern = pattern.replace(replaceRegex, function(string, name, offset) {
672 var parts = this.extractParts_(pattern);
710 * @param {string} pattern Subpattern that needs to be parsed as plural pattern.
714 goog.i18n.MessageFormat.prototype.parseOrdinalBlock_ = function(pattern) {
717 pattern = pattern.replace(replaceRegex, function(string, name) {
726 var parts = this.extractParts_(pattern);