Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
Setup
Console
Command
_files
phrases
TestPhrases.php
Go to the documentation of this file.
1
<?php
2
/***
3
* Copyright © Magento, Inc. All rights reserved.
4
* See COPYING.txt for license details.
5
*/
6
7
use
Magento\Framework\Phrase
;
8
13
class
TestPhrases
14
{
15
public
function
awesomeFunction
()
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
}
93
}
TestPhrases\awesomeFunction
awesomeFunction()
Definition:
TestPhrases.php:15
__
__()
Definition:
__.php:13
TestPhrases
Definition:
TestPhrases.php:13
Magento\Framework\Phrase
Definition:
Phrase.php:17
Magento\Framework\Phrase