Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
TestPhrases Class Reference

Public Member Functions

 awesomeFunction ()
 

Detailed Description

@SuppressWarnings(PHPMD) @codingStandardsIgnoreStart

Definition at line 13 of file TestPhrases.php.

Member Function Documentation

◆ awesomeFunction()

awesomeFunction ( )

Definition at line 15 of file TestPhrases.php.

16  {
17  $str1 = 'str1';
18  $str2 = 'str2';
19 
20  // Simple
21  $simpleCases = [
22  new Phrase('simple text'),
23  new Phrase('simple text with 1 string literal placeholder %1', 'arg'),
24  new Phrase('simple text with 1 variable placeholder %1', $str1),
25  new Phrase('simple text with multiple placeholders %1 %2', $str1, $str2),
26  ];
27 
28  // Phrase objects
29  $phraseObjects = [
30  // Single concatenation
31  new Phrase('first part'
32  . ' second part'),
33  new Phrase('first part' . ' second part' . ' third part'),
34 
35  // Multiple concatenation
36  new Phrase('first part' . ' second part with one string literal placeholder %1', 'arg'),
37  new Phrase('first part of concat' . ' second part with one variable placeholder %1', $str1),
38  new Phrase('first part of concat' . ' second part with two placeholders %1, %2', $str1, $str2),
39  new Phrase('first part of concat' . ' second part' . ' third part with one placeholder %1', 'arg'),
40  new Phrase(
41  'first part of concat' . ' second part' . ' third part with two placeholders %1, %2',
42  $str1,
43  $str2
44  ),
45 
46  // Escaped quotes
47  new Phrase('string with escaped \'single quotes\''),
48  new Phrase('string with placeholder in escaped single quotes \'%1\'', 'arg'),
49  new Phrase('string with "double quotes"'),
50  new Phrase('string with placeholder in double quotes "%1"', 'arg'),
51  ];
52 
53  $singleQuoteTranslateFunctions = [
54  // Single concatenation
55  __('first part' . ' second part'),
56  __('first part' . ' second part' . ' third part'),
57 
58  // Multiple concatenation
59  __('first part' . ' second part with one string literal placeholder %1', 'arg'),
60  __('first part of concat' . ' second part with one variable placeholder %1', $str1),
61  __('first part of concat' . ' second part with two placeholders %1, %2', $str1, $str2),
62  __('first part of concat' . ' second part' . ' third part with one placeholder %1', 'arg'),
63  __('first part of concat' . ' second part' . ' third part with two placeholders %1, %2', $str1, $str2),
64 
65  // Escaped quotes
66  __('string with escaped \'single quotes\''),
67  __('string with placeholder in escaped single quotes \'%1\'', 'arg'),
68  __('string with "double quotes"'),
69  __('string with placeholder in double quotes "%1"', 'arg'),
70  ];
71 
72  $doubleQuoteTranslateFunctions = [
73  // Single concatenation
74  __("first part" . " second part"),
75  __("first part" . " second part" . " third part"),
76 
77  // Multiple concatenation
78  __("first part" . " second part with one string literal placeholder %1", "arg"),
79  __("first part of concat" . " second part with one variable placeholder %1", $str1),
80  __("first part of concat" . " second part with two placeholders %1, %2", $str1, $str2),
81  __("first part of concat" . " second part" . " third part with one placeholder %1", "arg"),
82  __("first part of concat" . " second part" . " third part with two placeholders %1, %2", $str1, $str2),
83 
84  // Escaped quotes
85  __("string with 'single quotes'"),
86  __("string with placeholder in single quotes '%1'", "arg"),
87  __("string with escaped \"double quotes\""),
88  __("string with placeholder in escaped double quotes \"%1\"", "arg"),
89  ];
90 
91  $unclosedApostrophePhrase = __('string that\'s got an unclosed single quote in it');
92  }
__()
Definition: __.php:13

The documentation for this class was generated from the following file: