Hello world', array(), ); $cases[] = array(// text, no arg '
{{ts("Hello world")}}
', array('Hello world'), ); $cases[] = array(// text, no arg, alternate text '
{{ts("Good morning, Dave")}}
', array('Good morning, Dave'), ); $cases[] = array(// text, with arg '
{{ts("Hello world", {1: "whiz"})}}
', array('Hello world'), ); $cases[] = array(// text, not really ts(), no arg '
{{clients("Hello world")}}
', array(), ); $cases[] = array(// text, not really ts(), with arg '
{{clients("Hello world", {1: "whiz"})}}
', array(), ); $cases[] = array(// two strings, duplicate '
{{ts("Hello world")}}

{{ts("Hello world")}}

', array('Hello world'), ); $cases[] = array(// two strings, addition '
{{ts("Hello world") + "-" + ts("How do you do?")}}

', array('Hello world', 'How do you do?'), ); $cases[] = array(// two strings, separate calls '
{{ts("Hello world")}}

{{ts("How do you do?")}}

', array('Hello world', 'How do you do?'), ); $cases[] = array(// single quoted '
{{ts(\'Hello world\')}}
', array('Hello world'), ); $cases[] = array(// unclear string '
{{ts(message)}}
', array(), ); $cases[] = array(// ts() within a string '
{{ts("Does the ts(\'example\') notation work?")}}
', array('Does the ts(\'example\') notation work?'), ); $cases[] = array(// attribute, no arg '
', array('Hello world'), ); $cases[] = array(// attribute, with arg '
', array('Hello world'), ); $cases[] = array(// attribute, two strings, with arg '
', array('Hello world', 'How do you do, %1?'), ); $cases[] = array(// trick question! Not used on Smarty templates. '
{ts}Hello world{/ts}
', array(), ); return $cases; } /** * @param string $html * Example HTML input. * @param array $expectedStrings * List of expected strings. * @dataProvider translateExamples */ public function testParseStrings($html, $expectedStrings) { // Magic! The JS parser works with HTML! $actualStrings = CRM_Utils_JS::parseStrings($html); sort($expectedStrings); sort($actualStrings); $this->assertEquals($expectedStrings, $actualStrings); } }