Index: trunk/extensions/Maps/Maps.i18n.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | |
48 | 48 | // Mapsdoc parser hook |
49 | 49 | 'maps-mapsdoc-par-service' => 'The mapping service to display parameter documentation for.', |
| 50 | + 'maps-mapsdoc-par-language' => 'The language in which to display the documentation. If no such translation is available, English will be used instead.', |
50 | 51 | |
51 | 52 | // Coordinates parser hook |
52 | 53 | 'maps-coordinates-par-location' => 'The coordinates you want to format.', |
Index: trunk/extensions/Maps/includes/parserHooks/Maps_MapsDoc.php |
— | — | @@ -15,6 +15,15 @@ |
16 | 16 | class MapsMapsDoc extends ParserHook { |
17 | 17 | |
18 | 18 | /** |
| 19 | + * Field to store the value of the language parameter. |
| 20 | + * |
| 21 | + * @since 1.0.1 |
| 22 | + * |
| 23 | + * @var string |
| 24 | + */ |
| 25 | + protected $language; |
| 26 | + |
| 27 | + /** |
19 | 28 | * No LSB in pre-5.3 PHP *sigh*. |
20 | 29 | * This is to be refactored as soon as php >=5.3 becomes acceptable. |
21 | 30 | */ |
— | — | @@ -57,8 +66,13 @@ |
58 | 67 | |
59 | 68 | $params['service'] = new Parameter( 'service' ); |
60 | 69 | $params['service']->addCriteria( new CriterionInArray( $GLOBALS['egMapsAvailableServices'] ) ); |
61 | | - $params['service']->setDescription( wfMsg( 'maps-mapsdoc-par-service' ) ); |
| 70 | + $params['service']->setDescription( wfMsgForContent( 'maps-mapsdoc-par-service' ) ); |
62 | 71 | |
| 72 | + $params['language'] = new Parameter( 'language' ); |
| 73 | + $params['language']->setDefault( $GLOBALS['wgLanguageCode'] ); |
| 74 | + //$params['language']->addCriteria( new CriterionInArray( ) ); |
| 75 | + $params['language']->setDescription( wfMsgForContent( 'maps-mapsdoc-par-language' ) ); |
| 76 | + |
63 | 77 | return $params; |
64 | 78 | } |
65 | 79 | |
— | — | @@ -71,7 +85,7 @@ |
72 | 86 | * @return array |
73 | 87 | */ |
74 | 88 | protected function getDefaultParameters( $type ) { |
75 | | - return array( 'service' ); |
| 89 | + return array( 'service', 'language' ); |
76 | 90 | } |
77 | 91 | |
78 | 92 | /** |
— | — | @@ -85,12 +99,27 @@ |
86 | 100 | * @return string |
87 | 101 | */ |
88 | 102 | public function render( array $parameters ) { |
| 103 | + $this->language = $parameters['language']; |
| 104 | + |
89 | 105 | $params = $this->getServiceParameters( $parameters['service'] ); |
90 | 106 | |
91 | 107 | return $this->getParameterTable( $params ); |
92 | 108 | } |
93 | 109 | |
94 | 110 | /** |
| 111 | + * Message function that takes into account the language parameter. |
| 112 | + * |
| 113 | + * @since 1.0.1 |
| 114 | + * |
| 115 | + * @param string $key |
| 116 | + * |
| 117 | + * @return string |
| 118 | + */ |
| 119 | + protected function msg( $key ) { |
| 120 | + return wfMsgReal( $key, array(), true, $this->language ); |
| 121 | + } |
| 122 | + |
| 123 | + /** |
95 | 124 | * Returns the wikitext for a table listing the provided parameters. |
96 | 125 | * |
97 | 126 | * @since 1.0 |
— | — | @@ -110,11 +139,11 @@ |
111 | 140 | |
112 | 141 | if ( count( $tableRows ) > 0 ) { |
113 | 142 | $tableRows = array_merge( array( |
114 | | - '!' . wfMsg( 'validator-describe-header-parameter' ) ."\n" . |
115 | | - '!' . wfMsg( 'validator-describe-header-aliases' ) ."\n" . |
116 | | - '!' . wfMsg( 'validator-describe-header-type' ) ."\n" . |
117 | | - '!' . wfMsg( 'validator-describe-header-default' ) ."\n" . |
118 | | - '!' . wfMsg( 'validator-describe-header-description' ) |
| 143 | + '!' . $this->msg( 'validator-describe-header-parameter' ) ."\n" . |
| 144 | + '!' . $this->msg( 'validator-describe-header-aliases' ) ."\n" . |
| 145 | + '!' . $this->msg( 'validator-describe-header-type' ) ."\n" . |
| 146 | + '!' . $this->msg( 'validator-describe-header-default' ) ."\n" . |
| 147 | + '!' . $this->msg( 'validator-describe-header-description' ) |
119 | 148 | ), $tableRows ); |
120 | 149 | |
121 | 150 | $table = implode( "\n|-\n", $tableRows ); |
— | — | @@ -146,7 +175,7 @@ |
147 | 176 | |
148 | 177 | $type = $parameter->getTypeMessage(); |
149 | 178 | |
150 | | - $default = $parameter->isRequired() ? "''" . wfMsg( 'validator-describe-required' ) . "''" : $parameter->getDefault(); |
| 179 | + $default = $parameter->isRequired() ? "''" . $this->msg( 'validator-describe-required' ) . "''" : $parameter->getDefault(); |
151 | 180 | if ( is_array( $default ) ) { |
152 | 181 | $default = implode( ', ', $default ); |
153 | 182 | } |
— | — | @@ -154,7 +183,7 @@ |
155 | 184 | $default = $default ? 'yes' : 'no'; |
156 | 185 | } |
157 | 186 | |
158 | | - if ( $default === '' ) $default = "''" . wfMsg( 'validator-describe-empty' ) . "''"; |
| 187 | + if ( $default === '' ) $default = "''" . $this->msg( 'validator-describe-empty' ) . "''"; |
159 | 188 | |
160 | 189 | return <<<EOT |
161 | 190 | | {$parameter->getName()} |