Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3191,23 +3191,26 @@ |
3192 | 3192 | return $array; |
3193 | 3193 | } |
3194 | 3194 | |
3195 | | -/* Get the normalised IETF language tag */ |
| 3195 | +/* Get the normalised IETF language tag |
| 3196 | + * @param $code String: The language code. |
| 3197 | + * @return $langCode String: The language code which complying with BCP 47 standards. |
| 3198 | + */ |
3196 | 3199 | function wfBCP47( $code ) { |
3197 | 3200 | $codeSegment = explode( '-', $code ); |
3198 | 3201 | foreach ( $codeSegment as $segNo => $seg ) { |
3199 | 3202 | if ( count( $codeSegment ) > 0 ) { |
3200 | 3203 | // ISO 3166 country code |
3201 | 3204 | if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) |
3202 | | - $codeBCP[$segNo] = strtoupper ( $seg ); |
| 3205 | + $codeBCP[$segNo] = strtoupper( $seg ); |
3203 | 3206 | // ISO 15924 script code |
3204 | 3207 | else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) |
3205 | 3208 | $codeBCP[$segNo] = ucfirst( $seg ); |
| 3209 | + // Use lowercase for other cases |
3206 | 3210 | else |
3207 | | - // Keep casing for other cases |
3208 | | - $codeBCP[$segNo] = $seg; |
| 3211 | + $codeBCP[$segNo] = strtolower( $seg ); |
3209 | 3212 | } else { |
3210 | | - // Keep casing for single segment |
3211 | | - $codeBCP[$segNo] = $seg; |
| 3213 | + // Use lowercase for single segment |
| 3214 | + $codeBCP[$segNo] = strtolower( $seg ); |
3212 | 3215 | } |
3213 | 3216 | } |
3214 | 3217 | $langCode = implode ( '-' , $codeBCP ); |