Commit graph

1336 commits

Author SHA1 Message Date
Antoine Musso
750db30d9b abstract utf8 validation fallback
Language class had a code snippet to verify whether a text is valid
UTF-8 though that could not be used from another place. The snippet use
mb_check_encoding() and fallback to some regex whenever mbstring is not
available.

* introduce StringUtils::isUtf8() which is mostly code moved out of the
  language class.
* Enhance regex readability by using an expanded regex (//x)
* Made the regex to recognize longer sequences
* Add some unit tests to the mbstring and the PHP native implementation
* An optional second parameter can be passed to isUtf8() to force the
  use of our PHP implementation. This is used for unit testing.

Change-Id: I4cf4dfe2eb02f046db1726f4654ba649e01419f2
2012-12-12 11:24:38 +00:00
jenkins-bot
f54344c8be Merge "Fix incorrect documentation for Language::getFormattedNsText()" 2012-12-10 14:51:25 +00:00
Siebrand Mazeland
fc816895cb Fix incorrect documentation for Language::getFormattedNsText()
Change-Id: I16e9deaa5c962f177dee83785ac5142d4681b75f
2012-12-10 11:53:03 +01:00
Siebrand
43bd63fde8 Merge "(Bug 38439) Attempt on fixing the suicidal LangObjCache" 2012-12-09 23:42:34 +00:00
Tim Starling
79e9df0dc7 Make Language::isValidBuiltInCode() return bool
Make Language::isValidBuiltInCode() return true or false, as
documented. Previously returned 0 or 1. Hacked around in I81ba3228.

Change-Id: Iaa7515095d687d745d878faaa957aae51737abf7
2012-12-04 10:11:43 +11:00
jeblad
121cf60119 (Bug 38439) Attempt on fixing the suicidal LangObjCache
This replaces the suicide of LangObjCache and replaces it with a
LRU of configurable length.

The patch seems to be functional when I dumped some debug info.

Patchset 2: Updated commit message, reformatted a few lines.
Patchset 3: Removed the "do not merge"

Change-Id: Iee2c796a0c4dd491e31425e04121a1bf0554d7c9
2012-11-28 10:10:33 +01:00
Nikerabbit
bb7d20b87a Merge "Clean up Language::markNoConversion()." 2012-11-23 13:01:08 +00:00
Liangent
c50cd60069 Always return something nice in Language::translateBlockExpiry()
Change-Id: I30a1950df5ae018cb9124392dc8d6e99ca3b98b8
2012-11-21 00:01:35 +08:00
Liangent
e01adbfc0b Clean up Language::markNoConversion().
* IRIs are getting more and more widely used these days so Chinese
  characters are also needed to be prevented from being converted
  in text of external links.
* So now all markNoConversion() functions in languages with variants
  do the same thing. Merge them into a single function in the
  Language class and drop implementations in individual languages.
* By the way rephrase phpdoc of that function, and (bug 24798) fix
  the link detection regex to use wfUrlProtocolsWithoutProtRel().
  Protocol-relative regex is excluded to avoid false positives.
* Add parser test for it.

Change-Id: I2ec0ac2b9b11221584adb72555168498de209d57
2012-11-18 03:46:53 +08:00
Tychay
8b08a7db91 Merge "Revert "Function for "pretty timestamps" that are human readable and understandable."" 2012-10-25 22:36:32 +00:00
Siebrand
74f037bcd0 Revert "Function for "pretty timestamps" that are human readable and understandable."
This reverts commit b218064865

Appears to have been merged prematurely. More comments were made after merge, there's an i18n technicality that I5840cc2f would address and there appear to be some design issues that have been discussed on wikitech-1 in thread http://lists.wikimedia.org/pipermail/wikitech-l/2012-October/064036.html
2012-10-25 10:22:16 +00:00
Reedy
881c1d30e4 Merge "Function for "pretty timestamps" that are human readable and understandable." 2012-10-25 00:58:19 +00:00
Andrew Garrett
b218064865 Function for "pretty timestamps" that are human readable and understandable.
Uses one of the following formats:
- Just now
- 1 minute ago
- 35 minutes ago
- 13:04
- Yesterday at 13:04
- Wednesday at 13:04
- July 16
- July 16, 2012

Change-Id: I53dcf54763c68f15fc4f59b2668001b0cf84adf3
2012-10-12 10:29:15 +02:00
Liangent
b9f7fe0bcf Display converted namespace names in Html::namespaceSelector().
By the way, the code to get converted titles and namespaces
has been cleaned up.

Change-Id: Ifcbd56c989d83b9d32dfa99e0b2f06d01e17a2bd
2012-10-10 16:53:17 +11:00
daniel
c546fae8ed merge latest master into Wikidata branch
Change-Id: Id4e0f40c03679c13d8934a6add99b5cd86d0437d
2012-10-08 13:58:54 +02:00
umherirrender
cb6657a178 Add missing version number to wfDeprecated calls
Change-Id: I8b9efaf5eafc6cfecb34d401574ce978899d3990
2012-10-05 20:26:00 +02:00
Siebrand
436405bdc3 Merge "Support explicit 0 and 1 forms for plural in PHP" 2012-10-04 07:04:23 +00:00
awjrichards
c381fea140 Merge "Clean up: Declare variables with public instead of var" 2012-09-28 22:25:45 +00:00
daniel
b6b686c13b merged master
Change-Id: I0ef7c7f33a5dc5855f38b20c03ddc5306f38ec66
2012-09-19 12:34:10 +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
Santhosh Thottingal
c1dff7112f For languages without plural forms, use them from fallback language
* Fixes Bug 40251 and this is alternate for I403a29e2
* This brings back the old mediawiki behavior for languages without
  defined plural rules
* Add a test for hu, which had issue as per Bug 40251

Change-Id: I345c305134a62d43c9dfedc5243981d0e77e326d
2012-09-15 12:49:44 -07:00
Marius Hoch
652c4be7c2 Clean up: Declare variables with public instead of var
Variables in classes should be declared using public $foo
instead of var $foo for various reasons. As we require PHP 5.3
we don't have to take care about that PHP4 left over, but can
get rid of it in favour of the more clear and better readable
public.
See also: http://php.net/manual/en/language.oop5.visibility.php
(Divided into several commits to keep reviewable)

Change-Id: Ic723d0347ab2e3c78bc0097345c68bbee3dc035a
2012-09-14 21:00:00 +02:00
daniel
9994968774 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 15:20:15 +02:00
Daniel Kinzler
392af46809 Revert "merged master"
This reverts commit 67bfdc7a68
2012-08-29 13:14:49 +00:00
daniel
67bfdc7a68 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 12:06:38 +02:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Nikerabbit
08e7fab367 Merge changes I1aa3b081,I65ee788c,I58a9cdfe
* changes:
  Adding JavaScript CLDR plural parser.
  CLDR plural parser in PHP
  CLDR Plural rules based plural form calculation
2012-08-23 18:40:31 +00:00
Tim Starling
fceb9bcb49 CLDR plural parser in PHP
Wrote a CLDR plural rule parser to replace the eval()-based one from
I58a9cdfe. It converts the infix notation of the XML files to a
sanitized RPN notation, referred to in external interfaces as the
"compiled" form. The RPN notation is cached and then executed by a
fast non-validating evaluator.

Timings for the largest rule in the XML file are ~1.2ms for
compilation and ~200us for execution.

Also:
* Lazy-load the plural rules when recache() requests them, instead of
  loading them for every request.
* Language::convertPlural() needs integer keys, and CLDR only gives
  string keys. The previous code was not mapping them so it didn't work
  at all. I just mapped them in the order they appear in the XML file,
  i.e. the first rule becomes MediaWiki's $pluralForm=0, the second
  becomes $pluralForm=1, etc. Not sure if there is a more rigorous way
  to do it.

Change-Id: I65ee788c1a8e5ee2ede2091990d86eb722749dd3
2012-08-22 12:55:50 +00:00
Siebrand Mazeland
4e1ccf0267 Replace deprecated wfMsg* calls with Message class calls.
Doing this in steps of roughly 100 changes per commit, so that it remains reviewable.

Change-Id: I4950fdf8be669b52446290768ece0b8df8399d5d
2012-08-20 22:52:17 +02:00
daniel
29719f846b merging latest master
Change-Id: I36b7f2f63ab8c08f8412d521dc68ea45c8b67711
2012-08-20 16:55:28 +02:00
Alex Monk
2fabea7eea Use wfMessage instead of deprecated wfMsg*
Or $this->msg in special pages.

Change-Id: I774a89d646615053c8424050e42ad95601f92543
2012-08-18 14:11:05 +02:00
Santhosh Thottingal
bbbcf089db CLDR Plural rules based plural form calculation
* Use the plurals.xml of CLDR for the plural rules of languages
* Use plurals-mediawiki.xml to override or extend the rules inside MW
* Remove the convertPlural method in each LanguageXX.php
* Parse and load the xml files in LocalisationCache
* Use the CLDRPluralRuleEvaluator.php for parsing the cldr plural rules
  (This is taken from Translate extension and might require a replacement
   parser without using eval)
* Add getPluralRules() to make the CLDR plural rules available to JS.

PS3: More method documentation, cleanup

Change-Id: I58a9cdfe60c7b9027bf031c91370472054f04ae2
2012-08-16 11:45:17 +10:00
daniel
c0b50eb47d merged master
Change-Id: I6afafe971afb3f38fc8f1e66ba409283b8a698f8
2012-08-02 11:01:22 +02:00
Amir E. Aharoni
8a4016f494 Add @since 1.20 to getDirMarkEntity
Change-Id: Ib74b68a85e470ef23685802af93c3ec66d50e1ed
2012-07-30 11:51:47 +03:00
Siebrand
f615a3b7af Merge "Making listToText() not break if passed a 1-item list." 2012-07-29 19:12:01 +00:00
Reedy
a9fd5e3b6c Add @since annotation to Language::formatExpiry()
Change-Id: I022762a3a5e6fa6e45824f963c9301a83930b850
2012-07-24 23:20:26 +01:00
daniel
d87135d706 merged master
Change-Id: Iad12ee382d6aeb1fab6fefb611d290b74865ea4b
2012-07-23 22:07:18 +02: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
Kaldari
e476f5f432 Making listToText() not break if passed a 1-item list.
Change-Id: I25f36d25a106e2e024d4de334b0396f95792d72b
2012-07-17 15:38:45 -07:00
Siebrand
e9e59c1b2f Merge "(bug 37587) Enforce language codes to be html safe" 2012-07-13 19:47:33 +00:00
Antoine Musso
12e608e3d5 converts '@fixme' to '@todo FIXME'
@fixme is simply not recognized by doxygen whereas @todo is used to
generate a nice ... todo list!!

Change-Id: If956c0a164373126ce48b791d45c56962034eecd
2012-07-10 17:16:46 +02:00
Niklas Laxström
f06864bce8 (bug 37587) Enforce language codes to be html safe
Fixes bug 37587 and many other issues which
might or might not have been reported yet.

Change-Id: I612b90931a0261990bcd294fdb12cfba930c8c2f
2012-07-09 12:51:56 -07:00
Antoine Musso
86021805a4 Revert "(bug 32297) Use symbolic names, not offsets for a default timezone."
This reverts commit 3056b8dfd2.

Change-Id: I29cf9a5389709b30f869072ed836cb5b85ba5106
2012-07-02 13:12:16 +02:00
Siebrand
5e18423043 Merge "(bug 32297) Use symbolic names, not offsets for a default timezone." 2012-07-01 15:10:08 +00:00
daniel
b801fa8b3b merged master
Change-Id: I6cf08c09c7d9b38ecce0b2bbed61431939edd7d4
2012-06-20 19:13:16 +02:00
Reedy
8d35752a85 Minor additions to documentation stuff
Change-Id: I79417ce790c22a3f6ad1d24153da898901d1142f
2012-06-15 14:56:15 +01:00
daniel
a830943203 Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata 2012-06-14 12:43:43 +02:00
Catrope
37048169d8 Merge "(bug 36938) XSS in uselang parameter" 2012-06-13 17:43:19 +00:00
daniel
2679bd942c Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata 2012-06-07 16:36:58 +02:00
jeroendedauw
a7e28d2011 merged master
Change-Id: I4cf7b0f87cd571a6b50f66995dd9ad987a6ecdf8
2012-06-06 16:44:15 +02:00