Commit 58146e48 authored by alexpott's avatar alexpott

Issue #3004226 by Elendev, alexpott: Allow formatPlural's plural string not to...

Issue #3004226 by Elendev, alexpott: Allow formatPlural's plural string not to have '@count' in it in JavaScript
parent a24710ab
......@@ -1153,17 +1153,9 @@ function _locale_parse_js_file($filepath) {
( # capture plural string argument
(?: # non-capturing group to repeat string pieces
(?:
\' # match start of single-quoted string
(?:\\\\\'|[^\'])* # match any character except unescaped single-quote
@count # match "@count"
(?:\\\\\'|[^\'])* # match any character except unescaped single-quote
\' # match end of single-quoted string
\'(?:\\\\\'|[^\'])*\' # match single-quoted string with any character except unescaped single-quote
|
" # match start of double-quoted string
(?:\\\\"|[^"])* # match any character except unescaped double-quote
@count # match "@count"
(?:\\\\"|[^"])* # match any character except unescaped double-quote
" # match end of double-quoted string
"(?:\\\\"|[^"])*" # match double-quoted string with any character except unescaped double-quote
)
(?:\s*\+\s*)? # match "+" with possible whitespace, for str concat
)+ # match multiple because we supports concatenating strs
......
......@@ -50,3 +50,5 @@ Drupal.formatPlural(1, "Context Single Quoted plural", "Context Single Quoted @c
Drupal.formatPlural(1, "Context Double Quoted plural", "Context Double Quoted @count plural", {}, {"context": "Context string double quoted"});
Drupal.formatPlural(1, "Context !key Args plural", "Context !key Args @count plural", {'!key': 'value'}, {context: "Context string"});
Drupal.formatPlural(1, "No count argument plural - singular", "No count argument plural - plural");
......@@ -35,4 +35,6 @@ Drupal.formatPlural(1, "Context Unquoted plural", "Context Unquoted @count plura
Drupal.formatPlural(1, "Context Single Quoted plural", "Context Single Quoted @count plural", {}, { 'context': "Context string single quoted" });
Drupal.formatPlural(1, "Context Double Quoted plural", "Context Double Quoted @count plural", {}, { "context": "Context string double quoted" });
Drupal.formatPlural(1, "Context !key Args plural", "Context !key Args @count plural", { '!key': 'value' }, { context: "Context string" });
\ No newline at end of file
Drupal.formatPlural(1, "Context !key Args plural", "Context !key Args @count plural", { '!key': 'value' }, { context: "Context string" });
Drupal.formatPlural(1, "No count argument plural - singular", "No count argument plural - plural");
\ No newline at end of file
......@@ -86,6 +86,8 @@ public function testFileParsing() {
"Context Unquoted plural{$etx}Context Unquoted @count plural" => 'Context string unquoted',
"Context Single Quoted plural{$etx}Context Single Quoted @count plural" => 'Context string single quoted',
"Context Double Quoted plural{$etx}Context Double Quoted @count plural" => 'Context string double quoted',
"No count argument plural - singular{$etx}No count argument plural - plural" => '',
];
// Assert that all strings were found properly.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment