Index: trunk/tools/ToolserverI18N/TsIntuition.php |
— | — | @@ -645,9 +645,11 @@ |
646 | 646 | * Load a textdomain (if not loaded already). |
647 | 647 | * |
648 | 648 | * @param $domain string Name of the textdomain (case-insensitive) |
| 649 | + * @param $msgAction string What to do with the messages from the text domain |
| 650 | + * one of 'register', 'ignore'. |
649 | 651 | * @return False on error, (normalized) domainname if success. |
650 | 652 | */ |
651 | | - public function loadTextdomain( $domain ) { |
| 653 | + public function loadTextdomain( $domain, $msgAction = 'register' ) { |
652 | 654 | |
653 | 655 | // Generally validate input and protect against path traversal |
654 | 656 | if ( !TsIntuitionUtil::nonEmptyStr( $domain ) || strcspn( $domain, ":/\\\000" ) !== strlen( $domain ) ) { |
— | — | @@ -676,7 +678,7 @@ |
677 | 679 | } |
678 | 680 | |
679 | 681 | // Load it |
680 | | - $load = $this->loadTextdomainFromFile( $path, $domain ); |
| 682 | + $load = $this->loadTextdomainFromFile( $path, $domain, $msgAction ); |
681 | 683 | |
682 | 684 | // Return (normalized) domainname or false |
683 | 685 | return !!$load ? $domain : false; |
— | — | @@ -686,7 +688,7 @@ |
687 | 689 | /** |
688 | 690 | * @DOCME: |
689 | 691 | */ |
690 | | - public function loadTextdomainFromFile( $filePath = '', $domain = '' ) { |
| 692 | + public function loadTextdomainFromFile( $filePath = '', $domain = '', $msgAction = 'register' ) { |
691 | 693 | if ( !TsIntuitionUtil::nonEmptyStrs( $filePath, $domain ) ) { |
692 | 694 | $this->errTrigger( 'One or more arguments are missing', __METHOD__, E_NOTICE, __FILE__, __LINE__ ); |
693 | 695 | return false; |
— | — | @@ -702,14 +704,14 @@ |
703 | 705 | |
704 | 706 | // Parse it |
705 | 707 | $compact = compact( $this->includeVariables ); |
706 | | - $this->parseTextdomain( $compact, $domain, $filePath ); |
| 708 | + $this->parseTextdomain( $compact, $domain, $filePath, $msgAction ); |
707 | 709 | return true; |
708 | 710 | } |
709 | 711 | |
710 | 712 | /** |
711 | 713 | * @DOCME: |
712 | 714 | */ |
713 | | - private function parseTextdomain( $data, $domain, $filePath ) { |
| 715 | + private function parseTextdomain( $data, $domain, $filePath, $msgAction ) { |
714 | 716 | if ( !is_array( $data ) ) { |
715 | 717 | $this->errTrigger( 'Invalid $data passed to ' . __FUNCTION__, |
716 | 718 | __METHOD__, E_ERROR, __FILE__, __LINE__ ); |
— | — | @@ -721,13 +723,19 @@ |
722 | 724 | } |
723 | 725 | unset( $data['messages']['qqq'] ); // Workaround |
724 | 726 | |
725 | | - // Load the message into the blob |
726 | | - // overwrites the existing array of messages if it already existed |
727 | | - // If you need to add or overwrite some messages temporarily, |
728 | | - // use Itui::setMsg() or Itui::setMsgs() instead |
729 | | - foreach ( $data['messages'] as $langcode => $messages ) { |
730 | | - $this->availableLanguages[$langcode] = true; |
731 | | - $this->setMsgs( (array)$messages, $domain, $langcode ); |
| 727 | + if ( $msgAction === 'register' ) { |
| 728 | + // Load the message into the blob |
| 729 | + // overwrites the existing array of messages if it already existed |
| 730 | + // If you need to add or overwrite some messages temporarily, |
| 731 | + // use Itui::setMsg() or Itui::setMsgs() instead |
| 732 | + foreach ( $data['messages'] as $langCode => $messages ) { |
| 733 | + $this->availableLanguages[$langCode] = true; |
| 734 | + $this->setMsgs( (array)$messages, $domain, $langCode ); |
| 735 | + } |
| 736 | + } else { |
| 737 | + foreach ( array_keys( $data['messages'] ) as $langCode ) { |
| 738 | + $this->availableLanguages[$langCode] = true; |
| 739 | + } |
732 | 740 | } |
733 | 741 | |
734 | 742 | // Was there a url defined in the textdomain file ? |