MediaWiki REL1_33
LanguageEn.php
Go to the documentation of this file.
1<?php
30 function loadDefaultTables() {
31 $this->mTables = [
32 'en' => new ReplacementArray(),
33 'en-x-piglatin' => new ReplacementArray(),
34 ];
35 }
36
45 function translate( $text, $toVariant ) {
46 if ( $toVariant !== 'en-x-piglatin' ) {
47 return $text;
48 }
49
50 // Only process words composed of standard English alphabet, leave the rest unchanged.
51 // This skips some English words like 'naïve' or 'résumé', but we can live with that.
52 // Ignore single letters and words which aren't lowercase or uppercase-first.
53 return preg_replace_callback( '/[A-Za-z][a-z\']+/', function ( $matches ) {
54 $word = $matches[0];
55 if ( preg_match( '/^[aeiou]/i', $word ) ) {
56 return $word . 'way';
57 }
58
59 return preg_replace_callback( '/^(s?qu|[^aeiou][^aeiouy]*)(.*)$/i', function ( $m ) {
60 $ucfirst = strtoupper( $m[1][0] ) === $m[1][0];
61 if ( $ucfirst ) {
62 return ucfirst( $m[2] ) . lcfirst( $m[1] ) . 'ay';
63 }
64
65 return $m[2] . $m[1] . 'ay';
66 }, $word );
67 }, $text );
68 }
69}
70
76class LanguageEn extends Language {
77 function __construct() {
79
80 parent::__construct();
81
83 $this->mConverter = new EnConverter( $this, 'en', [ 'en', 'en-x-piglatin' ] );
84 }
85 }
86}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgUsePigLatinVariant
Whether to enable the pig Latin variant of English (en-x-piglatin), used to ease variant development ...
translate( $text, $toVariant)
Translates text into Pig Latin.
loadDefaultTables()
Dummy methods required by base class.
Base class for language conversion.
English.
Internationalisation code.
Definition Language.php:36
Wrapper around strtr() that holds replacements.