Jarry1250 has submitted this change and it was merged.
Change subject: Support non-duplicative sublocales (pt_BR, en_GB, etc.)
..
Support non-duplicative sublocales (pt_BR, en_GB, etc.)
Two parts:
(1) Read support
(2) Write support
Write support relies on rewriting pt-br to pt_BR and sorting it to the
top of the switch (as it is intended to be more specific than pt).
Read support is simply a case of rewriting pt_BR to pt-br.
Broken if a manual edit has introduced pt_PT, en_US system languages --
because Translate doesn't understand that en-us and en are synonymous.
Change-Id: Ic274351887bd0f72b33a9437e2b23ffae4ce3fb9
---
M SVGFormatReader.php
1 file changed, 17 insertions(+), 2 deletions(-)
Approvals:
Jarry1250: Verified; Looks good to me, approved
diff --git a/SVGFormatReader.php b/SVGFormatReader.php
index c25696a..d9616d2 100644
--- a/SVGFormatReader.php
+++ b/SVGFormatReader.php
@@ -324,6 +324,10 @@
foreach( $translations[$textId] as $language =
$translation ) {
// Sort out systemLanguage attribute
if( $language !== 'fallback' ) {
+ if ( strpos( $language, '-' ) !== false
) {
+ list( $before, $after ) =
explode( '-', $language );
+ $language = $before . '_' .
strtoupper( $after );
+ }
$translation['systemLanguage'] =
$language;
}
@@ -370,9 +374,19 @@
}
}
}
-
+ // Move sublocales to the beginning of their switch elements
+ $sublocales = $this-xpath-query(
+ //text[contains(@systemLanguage,'_')] . | .
//svg:text[contains(@systemLanguage,'_')]
+ );
+ $count = $sublocales-length;
+ for( $i = 0; $i $count; $i++ ) {
+ $firstSibling = $sublocales-item( $i
)-parentNode-childNodes-item( 0 );
+ $sublocales-item( $i )-parentNode-insertBefore(
$sublocales-item( $i ), $firstSibling );
+ }
// Move fallbacks to the end of their switch elements
- $fallbacks =
$this-xpath-query(//text[not(@systemLanguage)]|//svg:text[not(@systemLanguage)]);
+ $fallbacks = $this-xpath-query(
+ //text[not(@systemLanguage)] . | .
//svg:text[not(@systemLanguage)]
+ );
$count = $fallbacks-length;
for( $i = 0; $i $count; $i++ ) {
$fallbacks-item( $i )-parentNode-appendChild(
$fallbacks-item( $i ) );
@@ -424,6 +438,7 @@
$numChildren = $text-childNodes-length;
$hasActualTextContent =
TranslateSvgUtils::hasActualTextContent( $text );
$lang = $text-hasAttribute( 'systemLanguage' )
? $text-getAttribute( 'systemLanguage' ) : 'fallback';
+ $lang = str_replace( '_', '-', strtolower(
$lang ) );
$counter = 1;
for( $k = 0; $k $numChildren; $k++ ) {
$child = $text-childNodes-item( $k );
--
To view, visit https://gerrit.wikimedia.org/r/65460
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic274351887bd0f72b33a9437e2b23ffae4ce3fb9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/TranslateSvg
Gerrit-Branch: master
Gerrit-Owner: Jarry1250 jarry1...@gmail.com
Gerrit-Reviewer: Anomie bjor...@wikimedia.org
Gerrit-Reviewer: Jarry1250 jarry1...@gmail.com
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits