wiki.techinc.nl/includes/language
C. Scott Ananian 5ad8dea80a Use Bcp47Code when interfacing with Parsoid
It is very easy for developers and maintainers to mix up "internal
MediaWiki language codes" and "BCP-47 language codes"; the latter are
standards-compliant and used in web protocols like HTTP, HTML, and
SVG; but much of WMF production is very dependent on historical codes
used by MediaWiki which in some cases predate the IANA standardized
name for the language in question.

Phan and other static checking tools aren't much help distinguishing
BCP-47 from internal codes when both are represented with the PHP
string type, so the wikimedia/bcp-47-code package introduced a very
lightweight wrapper type in order to uniquely identify BCP-47 codes.
Language implements Bcp47Code, and LanguageFactory::getLanguage() is
an easy way to convert (or downcast) between Bcp47Code and Language
objects.

This patch updates the Parsoid integration code and the associated
REST handlers to use Bcp47Code in APIs so that the standalone Parsoid
library does not need to know anything about MediaWiki-internal codes.
The principle has been, first, to try to convert a string to a
Bcp47Code as soon as possible and as close to the original input as
possible, so it is easy to see *why* a given string is a BCP-47 code
(usually, because it is coming from HTTP/HTML/etc) and we're not stuck
deep inside some method trying to figure out where a string we're
given is coming from and therefore what sort of string code it might
be.  Second, we've added explicit compatibility code to accept
MediaWiki internal codes and convert them to Bcp47Code for backward
compatibility with existing clients, using the @internal
LanguageCode::normalizeNonstandardCodeAndWarn() method.  The intention
is to gradually remove these backward compatibility thunks and replace
them with HTTP 400 errors or wfDeprecated messages in order to
identify and repair callers who are incorrectly using
non-standard-compliant language codes in web standards
(HTTP/HTML/SVG/etc).

Finally, maintaining a code as a Bcp47Code and not immediately
converting to Language helps us delay or even avoid full loading of a
Language object in some cases, which is another reason to occasionally
push Bcp47Code (instead of Language) down the call stack.

Bug: T327379
Depends-On: I830867d58f8962d6a57be16ce3735e8384f9ac1c
Change-Id: I982e0df706a633b05dcc02b5220b737c19adc401
2023-03-13 13:25:09 -04:00
..
converters EnConverter: Process manual language conversion rules in Pig Latin 2023-03-07 14:54:19 -05:00
dependency Various doc fixes about false and null on method arguments/return types 2022-11-03 18:55:47 +01:00
Hook Remove deprecated MWTimestamp::getHumanTimestamp 2022-11-03 17:00:39 +00:00
ConverterRule.php Reorg: Namespace the Title class 2023-03-02 08:46:53 -05:00
ILanguageConverter.php Don't clear LanguageConverter display title when converting ToC 2023-03-09 13:08:01 -05:00
Language.php Merge "Language: Hard-deprecate Language::factory/getParentLanguage" 2023-03-10 17:03:37 +00:00
LanguageCode.php Use Bcp47Code when interfacing with Parsoid 2023-03-13 13:25:09 -04:00
LanguageConverter.php Don't clear LanguageConverter display title when converting ToC 2023-03-09 13:08:01 -05:00
LanguageConverterFactory.php Merge "Implement LanguageConverter for sh.wiki" 2022-11-24 22:28:46 +00:00
LanguageConverterIcu.php Language: Turn public properties into Getters in LanguageConverter based hierarchy 2021-02-03 15:17:42 +02:00
LanguageConverterSpecific.php Reorg: Namespace the Title class 2023-03-02 08:46:53 -05:00
LanguageFactory.php Make LanguageFactory::getParentLanguage() consistent with ::getLanguage() 2023-01-31 11:33:22 -05:00
LanguageFallback.php Language: More specific PHPDocs in Language class and related 2022-08-15 15:52:59 +00:00
LanguageNameUtils.php ParserTestRunner: set the user language to variant when present (take 2) 2023-02-21 17:59:34 -05:00
LCStore.php language: Add missing @ingroup, subgroup "Languages" and ungroup files 2022-06-28 17:12:46 -07:00
LCStoreCDB.php language: Add missing @ingroup, subgroup "Languages" and ungroup files 2022-06-28 17:12:46 -07:00
LCStoreDB.php rdbms: Remove Database::attributesFromType and hard-deprecate ::factory 2023-02-23 17:59:54 +00:00
LCStoreNull.php language: Add missing @ingroup, subgroup "Languages" and ungroup files 2022-06-28 17:12:46 -07:00
LCStoreStaticArray.php LCStoreStaticArray: atomically replace the cache file 2022-12-01 13:35:30 +11:00
LocalisationCache.php Make use of ??= in more places 2022-12-17 01:10:13 +00:00
LocalisationCacheBulkLoad.php Use array_key_first()/array_key_last() in some places 2022-10-21 15:01:59 +11:00
Message.php Reorg: Namespace the Title class 2023-03-02 08:46:53 -05:00
MessageCache.php Reorg: Namespace the Title class 2023-03-02 08:46:53 -05:00
MessageLocalizer.php Fix some @stable for ... annotations to use @stable to ... 2021-07-08 02:54:59 +00:00
RawMessage.php Make use of ??= in more places 2022-12-17 01:10:13 +00:00
TrivialLanguageConverter.php Don't clear LanguageConverter display title when converting ToC 2023-03-09 13:08:01 -05:00