Commit graph

148 commits

Author SHA1 Message Date
Timo Tijhof
b4bac102b6 tests: Clean up file headers
* Remove redundant @licence/@license from test suite files.
  They already have full licence headers. And @licence raises a
  warning in Doxygen.

* Fix weird messes of comments inside comments and other things.

Change-Id: I38da8ca76330f72b8dc22b0ecf1ea69d5ea55ede
2015-04-01 00:17:12 +01:00
umherirrender
0d39b3bb0d Move Test files under same folder structure where class is (/languages/)
Change-Id: I25c99272a1c2e318e6c61b4a497bf04886430e9b
2015-01-10 19:53:59 +00:00
Santhosh Thottingal
8dc3631093 Update plural data to CLDR 26
* The updates include incompatible changes for plural forms in Russian,
  Prussian, Tagalog, Manx and several languages that fall back to Russian.
  In addition there are minor changes for other languages.
* Test cases were updated to reflect these changes.

Bug: 62861
Change-Id: I7cce477925330fe5bbf51a8470060dc1223981d0
2014-10-27 08:30:34 +00:00
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
jsahleen
00a5c07b5c Fixes Algerian messages file so it does not convert to Arabic digits.
Bug: 69172
Change-Id: I8ba9e135daa2fc80907703b1023172c680fa571b
2014-08-07 09:47:39 +01: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
Amir E. Aharoni
fab8c6f541 Add grammar forms for Russian
This adds support for the Russian name of Wikimedia Commons.

Change-Id: If531e9ff8f46ac5294b117eec43172b4975e2ad6
2014-07-04 12:35:59 +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
umherirrender
e10ee4304e Adjust indent of some comment blocks
Change-Id: Ic25419490fa6a35c11ccc2b7810527e6661e027c
2014-05-01 18:46:34 +00: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
4ede8c2e9d Pass phpcs-strict on some test files (11/11)
Woo!

Change-Id: I9fc116dfdf18c2772d047adb5bb14535d0bd39ed
2014-04-24 13:51:05 -07: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
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02:00
Siebrand Mazeland
8e0c0a9fc9 Preparations for migrating core to use JSON based i18n
LocalisationCache and Language have to take the JSON files into account
in deciding if a language is present or not.

Standardizing language validity checking with isSupportedLanguage
and isValidBuiltInCode.

Co-Authored-By: Niklas Laxström <niklas.laxstrom@gmail.com>
Co-Authored-By: Siebrand Mazeland <siebrand@kitano.nl>
Change-Id: I35bbb3a7a145fc48d14fff620407dff5ecfdd4fc
2014-04-01 14:22:03 -07:00
umherirrender
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00: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
jenkins-bot
ea48400750 Merge "Add test to validate special page aliases" 2014-03-06 14:18:15 +00:00
Santhosh Thottingal
f50d3eb61e Update Russian(ru) plural rules to CLDR 24
Russian (ru) plural rules have a major change. The 'few' form is
merged with the 'other' form. The current forms are 'one', 'many', 'other'.
In MW ru plural rules were overridden using convertPlural methdod
in LanguagesRu.php with 3 forms.

Effectively forms[1] and forms[2] are swapped.

Followup: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6

Bug: 56931
Change-Id: Ia5779e42315d3f41f52dce2bfffaee0a4297d23b
2014-01-03 13:46:19 +05:30
Santhosh Thottingal
1441f511a2 Update plural rules to CLDR 24
Updated plurals.xml with new data from CLDR 24.

This data is according to UTS #35 Rev 33.

Update the CLDRPluralRuleParser.js to version 1.1 from upstream
https://github.com/santhoshtr/CLDRPluralRuleParser

Changes to the plural rules:

* Hebrew override removed since CLDR 24 matches with MW plural rules.

* Updated the syntax of overridden rules to TR35 Rev 33 for
  Lower Sorbian (dsb), Upper Sorbian (hsb), Belarusian in Taraskievica
  orthography (be_tarask), Old Church Slavonic (cu), Bhojpuri (bho),
  Samogitian (sgs).

* Removed Manx (gv) override. See I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608.

* Removed the overriden convertPlural method for Serbian from LanguageSr.php,
  since CLDR 24 matches with MW rules. Updated and added more tests.
  Tests updated for Serbocroatian (sh), too. Old CLDR versions had 4 plural
  rules and MW had only 3. In CLDR 24, the form 'many' was removed and it
  became identical to the MW. Same for Bosnian (bs) and Croatian (hr).
  Also for variants sr-ec and sr-el

* Macedonian (mk) used to count 11 as 'other' form.
  CLDR 24 counts it as 'one'.
  Not overriding, using CLDR 24 here.
  Updated the tests. MW will not override this.

* Armenian (hy) used to count 0 as 'other'.
  Now it is 'one' form.
  Updated the tests. MW will not override this.

* Latvian (lv) used to count only 0 as 'zero' form, but CLDR 24, any number
  satisifying the following formula is counted as zero:
  n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
  Examples: 0, 10~20, 30, 40, 50, 60, 100.
  Updated the tests accordingly. Not overriding it in MW.
  Users will see different plural form for the above numbers.

* Removed Ukranian custom plural rule since it match with MW

* Russian (ru) plural rules have a major change.
  The 'few' form is merged with the 'other' form.
  The current forms are 'one', 'many', 'other'.
  In MW ru plural rules were overridden using convertPlural methdod
  in LanguagesRu.php with 3 forms.
  Effectively forms[1] and forms[2] are swapped.
  This will affect the messages, and such messages
  must be reviewed and updated. This change is not included in this patch and
  wil be done separately.

Russian is the only remaining language class with convertPlural method overridden.

Notable impact on the exising messages:

* For languages ru, uk, be_tarask, sr, For the special case
  of two plural forms and first mapped to 1 and rest to the other form, syntax like
  {{plural:$1|1=one|other}} should be used.

For further information regarding each of the above language changes, see
1. http://unicode.org/cldr/trac/ticket/3727
2. http://goo.gl/H2HEz

CLDR 24 can handle fractions. Ideally it should start working
in MW without any code changes, but MW language test suite
does not have enough tests to confirm.

Followup: e571717e06

Bug: 56931
Change-Id: I9930b290d004667a3bb09e5c1663ec2c9c27d8a6
2014-01-03 11:53:10 +05:30
jenkins-bot
c9eaaf7093 Merge "Plural rules: updates for UTS #35 Rev 33" 2013-12-23 14:00:34 +00:00
Tim Starling
e571717e06 Plural rules: updates for UTS #35 Rev 33
* New operands i, v, w, f, t
* New operators =, !=, %
* Ignore "samples", which are basically unit tests embedded in rule
  specifications
* Ignore the new "other" rules, which have an empty condition. It
  doesn't really makes sense to parse them, since the empty condition
  means special handling should be done in the caller, it is not
  equivalent to an unconditional true or false.
* Trailing zero support requires that the input number be a string.
  Documented this.
* Fixed some comments
* Added test cases for new features

Bug: 56931
Change-Id: I96986c0c664f785e75b0a4ced2ec9e37b72681c1
2013-12-13 11:53:29 +11:00
Santhosh Thottingal
3e6cb8ac1a Correct the plural forms for Manx (Gaelg)
Backported the plural rules from CLDR 24 as an override to CLDR 23 rules
exising in MediaWiki. The syntax for plural rules changed in CLDR 24, so
modified the syntax to fit the CLDR 23 syntax

Once we are ready with the updated parsers for CLDR 24(See bug 56931),
we should remove the override.

Since we remove the custom plural forms in MW in favor of CLDR,
the following changes comes into effect:

1. 'few' form used as 'zero' form in MW. Practially that make 'one' form used
as 'two' form and 'two' used as 'few' form.
This breaks existing gv {{PURAL}} usage as dicussed in the bug report

2. CLDR defines 'few' form as n % 100 = 0,20,40,60 but MW adds 80 also to that
list, ie  n % 100 = 0,20,40,60, 80. So with this patch, 80 is no longer considered
as 'few' plural form.

Bug: 47099
Change-Id: I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608
2013-12-11 12:05:43 +05:30
aude
49b987b7ca Add test to validate special page aliases
Bug 57410
Change-Id: I185f58a618a0f0632d464552a94d704afd000e94
2013-12-10 12:44:18 +00:00
Santhosh Thottingal
a35f710791 Make explicit plural forms work for Russian
Russian has overridden convertPlural method, that was not
taking care of explicit plural forms.

Follow up: I2a9f93567087babb896999f1214d3c56afc67c96

Bug: 54514
Change-Id: Ia977fa544b1d0e40222c7296b7145dcd6f93ecc2
2013-12-04 06:46:57 +00:00
Pavel Selitskas
81fc875c0b Handle explicit plural forms in custom convertPlural in language classes
A new protected method looks for explicitly defined forms.
Every overriden language class is required to use this method.

Includes tests.

Redoing old patch I6dc759e3dfb05d6673209ba00da6592a384d5300

Bug: 46422
Change-Id: I2a9f93567087babb896999f1214d3c56afc67c96
2013-12-03 12:50:02 +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
Dereckson
8c8ff51233 Improving CLDR Plural Rule Evaluator documentation.
Change-Id: Ic6581de7cc69dea7af0bee5596497db509d6b9ba
2013-11-22 02:17:31 +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
caec5f920a @covers tags for the rest of test files..
Change-Id: I0fafe80531325a412472ab7c9fc6d81c861b3751
2013-10-24 21:38:08 +01: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
Chad Horohoe
c9b831a02a Clean up language test cases objection construction
I have no clue how this ever actually worked under Zend, but it
definitely didn't with HHVM. Now it works on both.

Change-Id: I521dfb74f30306736adda5662598fd036ad9849b
2013-09-26 16:09:13 -07: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
Alexandre Emsenhuber
4742232b0d Fix bootstrap in unit tests
- Remove check for version, that version is already enforced in phpunit.php,
  so there is not point showing a warning for it is useless
- Remove call to MessageCache::destroyInstance(), there is no need for it,
  since $wgMessageCacheType is set in phpunit.php before running Setup.php
- Remove includes of bootstrap.php in LanguageSrTest.php and LanguageUzTest.php

Change-Id: I4b2db6b3e6f001175e1a407c5add2972aade5e60
2013-05-03 21:45:06 +02: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
Siebrand Mazeland
6da93fc6f6 Update code formatting
Also update some previous inconsistencies pointed out by Krinkle in change IDs:
* Ide20743a2e84ff68549286120e6cff9d9f396f54
* I811ca957b6588085d67606ebc0cd4033a1e53839

Change-Id: Ife33b931870d0d7e04fcb40974997436d27f528f
2013-03-27 14:15:11 +01:00
Amir E. Aharoni
40c01f2492 Update plural rules for Hebrew
A recent CLDR update changed the plural rules for Hebrew
and added a "many" form. That rule has a mistake, however -
it is not supposed to include the number 10. This is reported as
http://unicode.org/cldr/trac/ticket/5828

This commit updates the plural overrides for Hebrew and makes
them closer to the latest CLDR, but with a fix for that rule.

It also updates the tests to include support for the new rule
and to make sure that the right fallbacks are used when
less than four rules are supplied, because usually that is
the case. It is thus a partial revert of the changes introduced
in I3d72e4105f6244b0695116940e62a2ddef66eb66 .

Mingle-Task: 2715

Change-Id: I1315e6900ef7a89bf246e748b786f7fc31a629c6
2013-03-22 15:21:50 +02: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
Kaldari
06b0967caa Allow the retrieval of the plural rule type for a given number
For example, find out which rule type should be applied for 5 items
in Arabic. The result would be 'few'.

This implementation should be non-disruptive and completely backwards
compatible (which is the main reason it isn't a lot simpler).

Change-Id: I3d72e4105f6244b0695116940e62a2ddef66eb66
2013-03-20 14:34:12 +05:30
Santhosh Thottingal
133f5952fd Remove custom plurals for Nso and Sl in favour of CLDR
Nso - Northern Sotho
Sl - Slovenian

Plural rules were not changed. They are same in CLDR and MW

Change-Id: I0e0c84352de2de8f58af5a9147ba18b0fe1fb39a
2013-03-20 08:35:59 +00:00
Santhosh Thottingal
43f5eb600b Move plural rules of Samogitian(sgs) to plurals-mediawiki.xml
* CLDR does not define plural rules for sgs.
* Port the plural rules present in LanguageSgs.php to CLDR plural
  definition syntax
* Remove LanguageSgs.php
* Update the tests, reorder/rename the plural form names

Change-Id: I44658402d69a6805cdfd189fe780eadee94056c7
2013-03-18 13:41:46 +05:30