Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99058753
PhutilPhtTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 18, 19:18
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Jan 20, 19:18 (2 d)
Engine
blob
Format
Raw Data
Handle
23670796
Attached To
rPHU libphutil
PhutilPhtTestCase.php
View Options
<?php
/**
* Test cases for functions in pht.php.
*/
final
class
PhutilPhtTestCase
extends
PhutilTestCase
{
public
function
testPht
()
{
PhutilTranslator
::
setInstance
(
new
PhutilTranslator
());
$this
->
assertEqual
(
'beer'
,
pht
(
'beer'
));
$this
->
assertEqual
(
'1 beer(s)'
,
pht
(
'%d beer(s)'
,
1
));
$english_locale
=
PhutilLocale
::
loadLocale
(
'en_US'
);
PhutilTranslator
::
getInstance
()->
setLocale
(
$english_locale
);
PhutilTranslator
::
getInstance
()->
setTranslations
(
array
(
'%d beer(s)'
=>
array
(
'%d beer'
,
'%d beers'
),
));
$this
->
assertEqual
(
'1 beer'
,
pht
(
'%d beer(s)'
,
1
));
$czech_locale
=
PhutilLocale
::
loadLocale
(
'cs_CZ'
);
PhutilTranslator
::
getInstance
()->
setLocale
(
$czech_locale
);
PhutilTranslator
::
getInstance
()->
setTranslations
(
array
(
'%d beer(s)'
=>
array
(
'%d pivo'
,
'%d piva'
,
'%d piv'
),
));
$this
->
assertEqual
(
'5 piv'
,
pht
(
'%d beer(s)'
,
5
));
}
public
function
getDateTranslations
()
{
// The only purpose of this function is to provide a static list of
// translations which can come from PhutilTranslator::translateDate() to
// allow translation extractor getting them.
return
array
(
'D'
=>
array
(
pht
(
'Sun'
),
pht
(
'Mon'
),
pht
(
'Tue'
),
pht
(
'Wed'
),
pht
(
'Thu'
),
pht
(
'Fri'
),
pht
(
'Sat'
),
),
'l'
=>
array
(
pht
(
'Sunday'
),
pht
(
'Monday'
),
pht
(
'Tuesday'
),
pht
(
'Wednesday'
),
pht
(
'Thursday'
),
pht
(
'Friday'
),
pht
(
'Saturday'
),
),
'S'
=>
array
(
pht
(
'st'
),
pht
(
'nd'
),
pht
(
'rd'
),
pht
(
'th'
),
),
'F'
=>
array
(
pht
(
'January'
),
pht
(
'February'
),
pht
(
'March'
),
pht
(
'April'
),
pht
(
'May'
),
pht
(
'June'
),
pht
(
'July'
),
pht
(
'August'
),
pht
(
'September'
),
pht
(
'October'
),
pht
(
'November'
),
pht
(
'December'
),
),
'M'
=>
array
(
pht
(
'Jan'
),
pht
(
'Feb'
),
pht
(
'Mar'
),
pht
(
'Apr'
),
pht
(
'May'
),
pht
(
'Jun'
),
pht
(
'Jul'
),
pht
(
'Aug'
),
pht
(
'Sep'
),
pht
(
'Oct'
),
pht
(
'Nov'
),
pht
(
'Dec'
),
),
'a'
=>
array
(
pht
(
'am'
),
pht
(
'pm'
),
),
'A'
=>
array
(
pht
(
'AM'
),
pht
(
'PM'
),
),
);
}
}
Event Timeline
Log In to Comment