Commit graph

1540 commits

Author SHA1 Message Date
Bartosz Dziewoński
c5b1097290 Hide Pig Latin language entirely if $wgUsePigLatinVariant is false
Previously, even if $wgUsePigLatinVariant was false, the language
would show up on Special:Preferences (and some other places) as
'en-x-piglatin - Igpay Atinlay'.

Follow-up to d8375bee24.

Change-Id: I08faacabca87c04299c7b535be8df1770e0a37ac
2017-06-16 20:43:28 +02:00
Liangent
d8375bee24 New language variant 'en-x-piglatin' for easier variant testing
Guarded by the $wgUsePigLatinVariant variable, off by default.

Pig Latin is a language game where words in English are altered
according to the following rules:

* Words starting with a vowel have a '-way' suffix appended.
* Words starting with a consonant have the initial consonants (or 'qu'
  group) moved to the end and an '-ay' suffix appended.

https://en.wikipedia.org/wiki/Pig_Latin

* Added 'en-x-piglatin' as a language name.
* Added 'en' to LanguageConverter::$languagesWithVariants.
* Added LanguageEn class and its corresponding EnConverter which
  provides one-way translation from English to Pig Latin.
* Some minor internal changes in code that assumed that English
  doesn't have a language class or converter.

Bug: T45547
Depends-On: I1d9691c784032669979f8109c9a5f65cbf4122c9
Change-Id: I7fa2d85d6364958c5138366e8b4504a2697a8731
2017-06-12 16:59:57 -04:00
Thiemo Mättig
f420839554 Fix incomplete Language::getDatePreferences() documentation
Look at languages/messages/MessagesEo.php for one of about a dozen real
world examples where this is set to false. All code calling
getDatePreferences checks if it got a truthy value first before using
it.

Change-Id: I4ef5c8be618d41039297325c9dd4cf554ea14559
2017-05-24 11:32:41 +02:00
Thiemo Mättig
8bbf6cb2eb Use more specific string[] type hint for language variants
This patch only touches PHPDoc documentation, nothing else.

Change-Id: Ia79d06425a3b8629c171cd68ae435c64dac86f46
2017-04-17 22:31:22 +02:00
Timo Tijhof
3a2a707546 Clean up remaining get_class() uses
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
2017-03-07 22:03:47 +00:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
James D. Forrester
3526417586 languages: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: Id2f9d229d17b8eee66b2ca4e3927f3f66ac62988
2017-02-28 00:33:38 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
2017-01-31 23:01:54 -05:00
Zhuyifei1999
0effd172ce translateBlockExpiry: Duration is block expiry minus current time
For relative timestamps in $str, strtotime( $str, $now ) returns an
absolute Unix timestamp $str since $now, and this timestamp is given
to $time. However, Language::formatDuration expects a time duration,
not an absolute timestamp. We obtain this duration from the difference
between $time, the absolute timestamp of block expiry, and $now, the
absolute timestamp of the time in which the block action happened.

Tests have been added to test both this patch and 01936fa, the patch
that caused this regression.

Bug: T156453
Change-Id: I6fd8c02dc3c6456067fe25cb9f33f5b4c78332aa
2017-01-28 07:22:00 +00:00
Bartosz Dziewoński
01936fa994 BlockLogFormatter: Durations are relative to block's timestamp, not Unix epoch
Also fixed legacy code in LogFormatter producing messages for IRC feed.

Bug: T55907
Change-Id: I0df19574f74210a91ce72c79188b6618f04ef9a2
2017-01-18 13:21:56 +00:00
This, that and the other
2b2cda890b Proper handling of invalid/unknown time zones
Currently, a user who has an invalid time zone stored in the database is
effectively locked out of their account on HHVM sites. This patch addresses
this by (1) preventing users from setting invalid time zones, and (2) not
throwing an unhandled exception if a user's TZ is unknown.

When the user saves their preferences, the code silently rewrites invalid
time zones to UTC. I think this is OK, since to cause this to happen you
have to manually muck around with the Preferences page DOM or submit the
form from a script.

Bug: T137182
Change-Id: I28c5e2ac9f2e681718c6080fb49b3b01e4af46dd
2017-01-05 05:24:45 +00:00
Amir E. Aharoni
6b03e2e88e Make the code for grammar data processing common
This makes the code for processing JSON files with
grammar transformations reusable by different languages
and applies the same logic to Russian and Hebrew.
It will be done to other languages in further patches.

This patch is not supposed to change any functionality,
and the tests are intact (except a comment in the test
for Hebrew - the class doesn't exist any longer).

PHP:
* Move the JSON grammar transformation data processing logic
  from LanguageRu.php to convertGrammar() in Language.php.
  By default all these data files are supposed to be
  processed identically, so the code should be common.
  If there is no JSON data file, nothing new happens.
* LanguageRu's own convertGrammar() method is removed.
* The LanguageHe class is removed, now that all its functionality
  is handled by generic JSON data processing in the Language class.
  LanguageHe.php file is removed from the repo and from autoloading.

JavaScript:
* Move the JSON grammar transformation data processing logic
  from ru.js to mediawiki.language.js.
* JavaScript grammar code files he.js and ru.js are removed
  from the repo and from Resources.php, because all the data
  is in JSON, and the default logic in mediawiki.language.js
  works for both languages.

Bug: T115217
Change-Id: I5e75467121c3d791bb84f9e6fdfcf07c1840f81a
2016-12-16 15:52:14 +02:00
jenkins-bot
9ac29c74ed Merge "Cleanup some incorrect return annotations" 2016-12-16 07:22:24 +00:00
Erik Bernhardson
f5f7795609 Fix PhanTypeInvalidLeftOperand in Language.php
Not entirely sure what's going on here. Best guess is phan isn't able
to figure out that array + mixed will result in an array, and then
adding validNamespaces (another array) is ok. Could make things a little
more explicit with array_merge, but this seems to work to remove the
issue without changing the meaning of the code.

Change-Id: I7031ae4e68878ec3198e47c55ab5de4d52a6d922
2016-12-13 11:54:15 -08:00
Erik Bernhardson
3becc477a9 Add script to support per-line @suppress annotations in Phan
Adds the functionality of per-line @suppress annotations. Phan already
supports per-class or per-method annotations, but does not have any
per-line support due to the PHP AST only returning comments that are
class/property/method level docblocks.

This is a bit of a hack, but get's the job done. Removes the
PhanTypeInvalidLeftOperand issue from blacklist and suppresses it
to demonstrate the supression works as expected.

Change-Id: I5066b3b431fb69175a711ee366e95f31c7c47639
2016-12-13 11:54:10 -08:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Yuri Astrakhan
6fe0f40e8c Comments: Added phabricator IDs to bz bug #s
Change-Id: Ia8d4e570e78c62e5c26bda0264fbf1efc74e58a2
2016-10-24 19:56:07 +00:00
Amire80
7d28ef7bd7 Add a @throws doc line to getGrammarTransformations() in Language.php
Follow up to
I6b9b29b7017f958d62611671be017f97cee73415

Change-Id: I65b4a7b482238d2df97639f41f05af8566686414
2016-10-21 15:34:19 -07:00
Amire80
9bf67190b3 Remove unreachable code after an exception
Follow up to
I6b9b29b7017f958d62611671be017f97cee73415

Change-Id: Ib3ccbb103097a50f04b798a4ff33eedc64e62aef
2016-10-21 13:39:07 -07:00
Amir E. Aharoni
df5a848de8 Make grammar data loadable as an RL module and usable in JS
* Load the data of this variable from a JSON file to the same
  data structure that ResourceLoader uses for digitTransformTable,
  pluralRules, etc.
* Change the JSON structure to ensure the order of the rules.
  Otherwise JavaScript processes the keys in a random order.
* Delete the grammar code from JS and replace it with
  the same logic that is used in PHP for processing the data.

For now this is done only for Russian.

The next step will be to make the PHP and JS
data processing logic reusable.

Bug: T115217
Change-Id: I6b9b29b7017f958d62611671be017f97cee73415
2016-10-21 12:25:16 -07:00
Andrew Harris
66844a8176 Change documentation of formatTimePeriod
Currently, the function formatTimePeriod does not have a very descriptive
documentation and has a TODO tag on it to change the documentation
Change the documentation to be more descriptive and remove the TODO

Change-Id: Idde711f1d3d6cbe0ecab0c3b49c68a4876d9e8b2
2016-10-13 17:43:44 +00:00
Fomafix
7de07e8991 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Change-Id: I06d9e043730accc4ae71b927e0f8229f0fc3b340
2016-10-11 17:25:10 +00:00
Amir Sarabadani
9850c542c6 Clean up array() syntax in docs, part VII
Last part

Change-Id: I38f015e2122ef4fd2d2141718bd889794c29f06c
2016-09-27 06:53:25 +03:30
zppix1
b60a467f58 Add Localisation to the links, add the link to Localisation in Languages/Language.php
Change-Id: I996d09f38a007195ba9734e13f10611c4ca1242c
2016-09-17 01:33:37 +00:00
Amir Sarabadani
aac0f95c22 introduce {{#time: xiz}} for days passed in the year
Discussed in the community

Change-Id: I4d5f638d7f0635df2a0a253a3b3bfe278a0aed0e
2016-08-26 18:38:04 +04:30
jenkins-bot
abb4d29b54 Merge "Introduce {{#time: xit}} for days in the month in Iranian calendar" 2016-08-23 12:54:48 +00:00
Chad Horohoe
02f9963f07 Remove useless check for MEDIAWIKI definition
This class isn't any more special than others, it can be autoloaded
like all the others and there's nothing to execute in the file scope

Change-Id: I7c415025c9c15cf19110f39452df3a14e44bf6f9
2016-08-18 10:15:10 -07:00
Amir Sarabadani
c13b8773fc Introduce {{#time: xit}} for days in the month in Iranian calendar
I was asked by community members to build this

Change-Id: I4b884ce3b72b2fcae6b0c11130bf91f9e67dedf2
2016-07-31 18:06:50 +04:30
Brion Vibber
3b5f60f2c8 Remove old Esperanto character conversion support
Deletes LanguageEo.php class which only had remains of the server-side
character conversion (sx <-> ŝ, etc). This is being obsoleted in favor
of client-side IMEs provided by UniversalLanguageSelector extension.

Removes deprecated $wgEditEncoding, which was only used for this.

Turns Language::recodeInput() and Language::recordForEdit() into no-ops
for any old or extension code that happened to still use them.

Bug: T62677
Change-Id: Ib647353538d258dee941f2f7c571191060bc9c7d
2016-07-18 19:20:49 +00:00
Marius Hoch
9ca0f6c620 Only attempt to calculate the TTL in Language::sprintfDate if needed
Change-Id: Ifd24c9206be05bb4fd2277efc574c9d1018e1957
2016-06-23 12:36:25 +02:00
Max Semenik
3b89194788 Move mbstring initializaton to Setup.php, add checks
Bug: T137509
Change-Id: Ib3496c9465a7b229b97793c6fa5dafb878c04968
2016-06-13 21:47:47 +00:00
Fomafix
796d62d034 Language: Introduce new method equals( Language $lang )
Use

 $lang->equals( $wgContLang )

instead of

 $lang->getCode() === $wgContLang->getCode()

Change-Id: Id7ed6a21ce5e2ea2887ec98c7bd9d3eba83d733b
2016-05-16 22:33:33 +00:00
Ricordisamoa
cd7da66fb5 Add missing 'public' keywords to some more Language methods
All of them are already being used outside the class:
* getMonthAbbreviation
* getMonthAbbreviationsArray
* getWeekdayName
* sprintfDate
* userAdjust
* date
* time
* timeanddate
* getMessage
* iconv
* ucfirst
* uc

Change-Id: I63ec93858cebc02cdf3b9b042eddf4ef620cc110
2016-05-04 16:02:39 +02:00
jenkins-bot
75cdcc9400 Merge "Fix wrong @return type hints in Language::tsTo… methods" 2016-04-19 12:12:34 +00:00
Thiemo Mättig
6209fe38e4 Fix wrong @return type hints in Language::tsTo… methods
Change-Id: Ic4dec8e8612021f010734037b6c3527bef2fe04a
2016-04-19 12:18:20 +02:00
jenkins-bot
bb333d91a4 Merge "Show absolute block expiry in user timezone on block logs" 2016-04-09 19:37:29 +00:00
umherirrender
afd72226b8 Show absolute block expiry in user timezone on block logs
For this add an user parameter to Language::translateBlockExpiry.
This allows the function to display the absolute block expiry in the
user's time zone. Use this when formatting block log entries.

This also avoids the use of $wgUser

Bug: T131241
Change-Id: If0a1d3c88bb4242a016eb9b2df115413de786149
2016-04-09 20:57:33 +02:00
Kevin Israel
5b48bf1b92 Clean up after "Kill mbstring fallbacks"
* Removed fallback code from Language, the associated data file
  (Utf8Case.ser), and the code to generate that data file.
* Removed comment in LanguageFi that "mb_substr has a compatibility
  function in GlobalFunctions.php".
* Removed check for mbstring in bench_utf8_title_check.php.
* In the tests for StringUtils::isUtf8():
  * Removed separate test for the non-mbstring code path.
  * Removed mentions of mbstring from function names and assertion
    messages, since mb_check_encoding() is now always used.
* Also updated the comment in StringUtils::isUtf8() referring to
  PHP 5.3, which is no longer supported in MediaWiki, to indicate
  that the same issue also exists in old versions of HHVM. (If
  we don't have to support 3.4 or older, then the function could
  be deprecated and removed if desired.)

Follows-up 943563062f.

Change-Id: I55e5cd534b849c6ea06a7fadacbbf34a12d87ebe
2016-04-07 09:02:37 -04:00
Ricordisamoa
aab4b2e078 Add missing 'public' keywords to some Language methods
All of them are already being used outside the class:
* getFallbackLanguages
* getBookstoreList
* getFormattedNamespaces
* getNsText
* getFormattedNsText
* getGenderNsText
* needsGenderDistinction
* getNamespaceAliases
* getNamespaceIds
* getNsIndex
* getVariantname
* getDatePreferences
* getDefaultDateFormat
* getDatePreferenceMigrationMap
* getImageFiles
* getExtraUserToggles
* getMessageFromDB
* getMonthName
* getMonthNamesArray
* getMonthNameGen

Change-Id: Iff5495596c5a711259c45b4d57c453aad9526a9a
2016-03-24 14:02:50 +01:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
jenkins-bot
8170af4935 Merge "Use an example with working digit transformation" 2016-03-14 09:54:30 +00:00
Siebrand Mazeland
b98dc6ced8 Update and correct documentation in Language class
Change-Id: I1d530bded0da7133f9b5120b515f32fc87507c84
2016-03-11 15:09:47 +00:00
Siebrand Mazeland
288e1ad503 Remove deprecated Language::getLangObj()
Was deprecated since 1.24. There were no uses in Gerrit extensions

Change-Id: I7ca08416d10fbba5222cb1a1fde75b697d354b09
2016-03-08 21:44:26 +00:00
Siebrand Mazeland
67d783b50e Remove deprecated Language::specialPage()
Was deprecated since 1.24. There were no uses in Gerrit extensions

Change-Id: If67456a62cb7d9688793d876508f0f168f3bb1ff
2016-03-08 21:43:21 +00:00
Siebrand Mazeland
182e45f31a Remove deprecated Language::GetLanguageName()
Was deprecated since 1.20. Uses in Gerrit extensions have been replaced.

Change-Id: I623e82ec1d9ade4da05f2eae15afdf65aa04109b
2016-03-08 21:38:59 +00:00
Siebrand Mazeland
19cd88808c Remove deprecated Language::getTranslatedLanguageNames()
Was deprecated since 1.20. There were no uses in Gerrit extensions

Change-Id: I0b16c0f146ecbee81921b5823b32776414f6945c
2016-03-08 20:26:51 +00:00
Siebrand Mazeland
4f03894063 Remove deprecated Language::getLanguageNames()
Was deprecated since 1.20. Uses in Gerrit extensions have been replaced.

Change-Id: I2011d3e209915ddbbafdbdfff0279ea7cc5b9125
2016-03-08 20:26:34 +00:00
Matthew Flaschen
b341b63243 Use an example with working digit transformation
Change-Id: I6424774a4cf720fe85a431ff12e5d5c61c9bfcde
2016-03-07 20:14:34 -05:00
Bartosz Dziewoński
c161c46d26 Improve code suffering from PHP 5.3's lack of support for foo()[]
I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored
everything involving isset(), unset() or array assigments, then
skimmed through the remaining results and changed things where they
made sense. These changes were not automated, so please review them.

Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
2016-02-28 22:49:20 +01:00