Commit graph

78 commits

Author SHA1 Message Date
umherirrender
cd80906d4a Change @return to start with type
MediaWiki default is "@return type Description", so set a type after
return and start the description with a capital letter. Also use the
more common spelling of boolean.

See http://phpdoc.org/docs/latest/references/phpdoc/tags/return.html for
more about @return

Change-Id: I4e5198822fe92836f9cef9918a9fc1a1a1e0a043
2014-08-20 20:35:41 +02:00
Chad Horohoe
fca0d37a2c Language::isValidBuiltInCode() should not accept uppercase input
The results of this function are used to decide whether a code is
valid for loading an i18n file without any further normalization.

Partially reverts 93348f3 which made the regular expression case-
insensitive. Per IRC discussion, language codes should always be
lowercase and it's up to callers to deal with that.

Change-Id: I8975c3374a37935080d9f7eca6a602e32f67a87b
2014-07-16 18:20:22 +00:00
Jackmcbarn
d998c8e96c Return a TTL when formatting times
Add an out parameter to Language::sprintfDate that returns the amount of
time that its output is valid for (e.g., an output format of 'Y-m-d' at
11:50 PM would be valid for 600 seconds).

Change-Id: I3f5a80aa4d303f92c97d24ab780af920894d24ef
2014-06-01 14:10:28 -04:00
jenkins-bot
ab2d63b53e Merge "Fix Language::parseFormattedNumber for lzh and zh-classical" 2014-04-25 07:13:29 +00:00
aude
60e1d9996c Fix Language::parseFormattedNumber for lzh and zh-classical
When parsing, filter any array values that are empty string
before using strtr php function so that strtr can handle
the array.

Bug: 64347
Change-Id: I94761caa70d44febfa0999c91048a01044fc1fbe
2014-04-25 08:52:54 +02:00
Siebrand Mazeland
69ec133bc5 Pass phpcs-strict on some test files (10/11)
Change-Id: I5624292143fcabe890779f5095eae735d7afb176
2014-04-24 13:50:56 -07:00
umherirrender
87fe91344e Remove # from dataProvider
Change-Id: Ie5414173b95e846d735827bffa34c73698e48c17
2014-04-18 19:10:38 +02:00
Ladsgroup
16a5102765 Change URLs to mediawiki.org in comments to HTTPS
These are only documentation fixes
http://www.mediawiki.org --> https://www.mediawiki.org

Change-Id: I62ad42be1a3aac410cc53e98ce79389ceddd8988
2014-03-20 16:59:46 +00:00
daniel
107bd92ec7 (bug #56685) make sure commafy can deal with strings.
Localization of numeric values should operate on the values as strings,
and should handle strings representign very large numbers gracefully.

Change-Id: I95394b96f9b70deb06ab818b54e08ac4ccb38c6c
2013-11-26 20:40:53 +01:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
UltrasonicNXT
87fe16c445 Prevent space before ellipsis when truncating
When truncating a string at a point where it contains a space (ie "hello
world" to 9 chars), the resultant string will have a space before the
ellipsis ("hello ..."). This is both gramatically incorrect and just looks
wrong, and is fixed by trimming the string before appending the ellipsis.

Change-Id: Iec86b17bfc8c50e4c1a96fd373861841fc57848d
2013-11-15 14:29:18 -04:00
addshore
46a17d0fc3 Cleanup /languages/* tests
This change:
 - Adds method scope
 - adds @covers tags
 - adds various @todos
 - fixes some comments

Before the changes tests ran with:
   1383 tests, 1412 assertions 10 skips
After changes the results remain the same

Change-Id: Iee57447bdb47026952ef5dcce6fed5dad0f80e52
2013-10-22 12:32:29 +02:00
Liangent
d0e3dc94c3 Add converted namespace names as aliases to avoid confusion.
Currently if the site language is zh and a user is using variant zh-tw,
namespace names from zh-hant are displayed because of the language
converter, but they're not accepted by MediaWiki as valid namespace names
by default because zh falls back to zh-hans.

For core namespaces, all converted namespace names are manually added as
$namespaceAliases in MessagesZh.php but it's not always done in extensions.
With this patch converted namespace names are automatically added as
namespace aliases when namespace aliases are loaded.

In some followup commit it makes sense to remove existing core namespace
aliases which were created for this reason.

Change-Id: I01873d9c64a9943afbb655d6203cec9ebd39fb72
2013-08-13 13:01:40 +00:00
jenkins-bot
b8f9b16b84 Merge "New function Language::getParentLanguage()." 2013-06-28 15:15:04 +00:00
Niklas Laxström
a7a693f4b0 Avoid exceptions by first checking language code validity
Bug: 49423
Change-Id: I3fd98ba08393856311a48fa40769027460c72ef9
2013-06-13 09:35:32 +00:00
Liangent
396e18a8e5 New function Language::getParentLanguage().
Change-Id: Ib2109176b7dfc7ec2d0ee827c804cf93ea83b9e5
2013-06-10 18:07:49 +00:00
Kevin Israel
d510d0c0c7 Language::convertPlural: check if matching form exists
It is possible that only explicit plural forms are specified, and
therefore, it is possible that none match. However, handling of
explicit forms came after the count( $forms ) check, so input such
as {{PLURAL:|1=}} would trigger a "PHP Notice: Undefined offset: -1".

Change-Id: I8494de8ceb9e0cfff7203c69c21f02b3731275af
Follows-Up: I50eb0c6d1c02ca936848d310de625ed1fe43d91a
2013-05-25 19:30:53 -04:00
jenkins-bot
9cd8ce5034 Merge "Add input checks for Language::sprintfDate()" 2013-04-29 08:50:08 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Siebrand Mazeland
35f0a66f32 Add input checks for Language::sprintfDate()
Check if the timestamp has a length of 14 characters and if it is numeric.
Throw an exception otherwise. Includes tests.

Bug: 47629
Change-Id: I9a4fd0af88cf20c2a6bd72fd7048743466c1600f
2013-04-26 10:05:18 +02:00
Brad Jorsch
e9e1b0a777 (bug 33454) Add timezone support to Language::sprintfDate
Add an optional timezone parameter to Language::sprintfDate, add format
characters eIOPTZ, and correct crU.

While we're at it, remove backwards-compatability code for 'N' and then
merge the existing switch cases for cr and wNzWtLoU that are basically
identical, since all those cases need to be changed anyway.

Bug: 33454
Change-Id: Iea1f78428bc0d32d6395818311dbe4b94d776c42
2013-04-09 22:49:04 +00:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
Siebrand Mazeland
ee93ce6699 Add space between number and unit of measure
Also update tests.

Spotted by Opraco in
https://translatewiki.net/wiki/Thread:Support/About_MediaWiki:Bitrate-kilobits/en

Change-Id: I81ad428ebc8b2511b871bf98540bc74508f00939
2013-03-12 19:40:47 +01:00
Niklas Laxström
cdef54377e Docs, typofix, additional testcase for I7be51e
Change-Id: I0ab17cb749c23b666e0bb1ee61fe7d424e717fde
2013-02-27 08:56:06 +00:00
jenkins-bot
78271824d2 Merge "(Bug 44987) Allow n=form in plural syntax" 2013-02-26 15:27:31 +00:00
Amir E. Aharoni
6848470450 Wrote proper skip reason
Change-Id: I80627dab1db279ee0b9d27ec929671bc458558b7
2013-02-18 23:58:43 +05:30
Siebrand Mazeland
feb9419a51 Update formatting
7 of n.

Change-Id: I07687a4381f29fd9fc73666e460f25769ed54092
2013-02-15 12:53:41 +00:00
Santhosh Thottingal
ff3df41363 (Bug 44987) Allow n=form in plural syntax
phpunit testcases included

Change-Id: I7be51e24a0b953dcd1f9cb21f54af9b4127a5cdb
2013-02-14 15:32:46 +05:30
jenkins-bot
75ef257c29 Merge "pass codesniffer on tests/" 2013-01-28 23:47:45 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Amir E. Aharoni
fee2b0045e (bug 41476) Implement Language::isKnownLanguageTag()
Change-Id: I130d8e0b397323e21058cf46510440da066fa12b
2013-01-28 09:10:11 +00:00
Amir E. Aharoni
4a25561370 (bug 41478) Implement Language::isWellFormedLanguageTag()
Change-Id: Ief5643e9a7d3883d6d131503087aca15207b0a44
2013-01-25 13:05:13 +02:00
Niklas Laxström
0e08362b40 (bug 41477) Add Language::isSupportedLanguage
Change-Id: If48c23fd580133bf78c19d4a0e8e00e74a639fa1
2013-01-21 08:47:53 +00:00
Yuri Astrakhan
8551f29ae2 Language::listToText cleanup with unit test
Change-Id: If88ab7da07e336fc5f6264c7d6b4f6ce542f99c9
2013-01-07 20:02:56 +00:00
IAlex
83aafac2b0 Merge "Do correct average year length arithmetic." 2012-12-29 19:18:05 +00:00
Liangent
70e300e270 Do correct average year length arithmetic.
We have ( 24 * 3 + 25 ) leap years in total every 400 years in the
Gregorian calendar.

Change-Id: I2ad9036473afa914ecf8ddcf99ce27e316178f76
2012-12-29 22:15:36 +08:00
Kaldari
5e13ecaa9b Fixing some variable names and comment formatting - no functional changes
Changing $_ to $number; changing $numberpart to $integerpart

Also adding a unit test for the commafy function

Change-Id: Iaf6dd027bd70722d316d1a9c10c9913fff8300ce
2012-12-24 07:47:21 +00:00
Liangent
c50cd60069 Always return something nice in Language::translateBlockExpiry()
Change-Id: I30a1950df5ae018cb9124392dc8d6e99ca3b98b8
2012-11-21 00:01:35 +08:00
Antoine Musso
a03bf9e27f tests: rm duplicate code in language classes
The language classes have been using the same setUp() tearDown() to
craft a new language object. I have abstracted that code in
LanguageClassesTestCase and made all the language test classes to extend
it. The language is interpolated directly from the class name and an
object for it can be retrieved with the getLang() method.

Change-Id: Ib931336ce219edabe2c72b7e9f04c976a500723e
2012-10-29 09:40:30 +01:00
Siebrand
5abe15bb9d Merge "SI standards for time units" 2012-10-17 23:09:49 +00:00
Federico Leva
31cb4c6b03 SI standards for time units
* Use "min" rather than "m".
* Add normal spaces to avoid hassles, no wrapping here anyway.

<https://translatewiki.net/wiki/Thread:Support/Abbreviation_for_'minute'>

Change-Id: I07f7aff41a831c88b82d6ddc53914372d6aec023
2012-10-13 18:03:08 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
Niklas Laxström
25c60c313a Support explicit 0 and 1 forms for plural in PHP
rails-i18n has the same, lets see if this is flexible
enough or whether we need to allow more complex expressions.

Change-Id: I50eb0c6d1c02ca936848d310de625ed1fe43d91a
2012-09-16 20:22:22 +00:00
Reedy
c50a8db395 Add testRomanNumerals
Up Language::romanNumeral() to work upto 10,000

Does anyone know how do do letters with an underscore ontop of them? ;)

Change-Id: Ib1b1415126af855ce5fb55f81b71534c26d84cc9
2012-07-23 12:15:19 +00:00
Reedy
88040226b6 Increase the readability of provideFormattableTimes by adding newlines
Change-Id: I7f96f44c2e18153ecfd7ea6d593229808a835a63
2012-07-18 14:51:28 +00:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
lupo
5b9731e08a (bug 36839) Use mb_check_encoding() if available.
This is not a real fix for the cause of the bug (which is a
pcre.recursion_limit that is far too low), but I do wonder
about the efficiency of using a regexp to test for valid
UTF-8 encoding. After all the regexp has to be compiled first
into a state machine.

Patch set 2: Php unit test for Language.checkTitleEncoding
Patch set 3: benchmark
Patch set 4: add benchmark for non-capturing subgroup in regexp, and
since that's faster than a capturing subgroup, use it in
checkTitleEncoding() in the regexp branch.
Patch set 5: use Tim's suggestion (once-only pattern) in the regexp
branch. Also add to benchmark.

Change-Id: I551f096921d4c9c57cbcb091b80ab5970ca86a9b
2012-05-31 14:21:36 +02:00
Jeroen De Dauw
77d2f16760 duration formatter, makes time in sec easy to read
The Language::formatDuration() method introduced by this patch let us
easily render an amount of seconds for easier human reading.

 $ maintenance/eval.php
 > var_dump( $wgLang->formatDuration( 1000 );
 string(25) "16 minutes and 40 seconds"

Also ran rebuildLanguage.php on Siebrands request

Change-Id: If287fb10e897d3d2374cf6eeae3bc5be00cdfc01
2012-04-13 13:54:04 +02:00
Sam Reed
c27fbf5330 Trim trailing whitespace
Add/improve documentation

Explicitly define a few variables

Change-Id: If0017770a0a47f8f6be178b5bde8ae6691f74b6a
2012-03-21 15:47:05 -07:00