Index: trunk/tools/ToolserverI18N/TsIntuition.php |
— | — | @@ -30,9 +30,10 @@ |
31 | 31 | private $localBaseDir = __DIR__; // to be moved to p_i18n |
32 | 32 | |
33 | 33 | private static $registeredTextdomains = array( |
34 | | - 'general' => array( 'file' => 'General.i18n.php' ), |
| 34 | + 'General' => array( 'file' => 'General.i18n.php' ), |
35 | 35 | 'Getwikiapi' => array( 'file' => 'Getwikiapi.i18n.php' ), |
36 | 36 | 'Jarry' => array( 'file' => 'Jarry.i18n.php' ), |
| 37 | + 'Monumentsapi' => array( 'file' => 'Monumentsapi.i18n.php' ), |
37 | 38 | 'Orphantalk2' => array( 'file' => 'Orphantalk2.i18n.php' ), |
38 | 39 | 'Svgtranslate' => array( 'file' => 'Svgtranslate.i18n.php' ), |
39 | 40 | 'Tsintuition' => array( 'file' => 'Tsintuition.i18n.php' ), |
— | — | @@ -558,12 +559,12 @@ |
559 | 560 | $domain = ucfirst( strtolower( $domain ) ); |
560 | 561 | |
561 | 562 | // Already loaded ? |
562 | | - if ( in_array( $domain, $this->loadedTextdomains ) ) { |
| 563 | + if ( in_array( $domain, $this->loadedTextdomains ) || !isset( self::$registeredTextdomains[$domain] ) ) { |
563 | 564 | return false; |
564 | 565 | } |
565 | 566 | |
566 | 567 | // File exists ? |
567 | | - $path = $this->localBaseDir . "/language/messages/" . $this->registeredTextdomains[$domain]['file']; |
| 568 | + $path = $this->localBaseDir . "/language/messages/" . self::$registeredTextdomains[$domain]['file']; |
568 | 569 | if ( !file_exists( $path ) ) { |
569 | 570 | $this->errTrigger( "Textdomain file not found for \"$domain\" at $path. Ignoring", __METHOD__, E_NOTICE, __FILE__, __LINE__ ); |
570 | 571 | return false; |
— | — | @@ -788,9 +789,9 @@ |
789 | 790 | } |
790 | 791 | |
791 | 792 | |
792 | | - |
793 | 793 | /* Output promo and dashboard backlinks |
794 | 794 | * ------------------------------------------------- */ |
| 795 | + |
795 | 796 | /** |
796 | 797 | * Show a link that explains that this tool has been |
797 | 798 | * localized via Toolserver Intuition and that they |
— | — | @@ -805,30 +806,60 @@ |
806 | 807 | } else { |
807 | 808 | $text = $this->msg( 'bl-mysettings-new', 'tsintuition' ); |
808 | 809 | } |
809 | | - $p = array( |
810 | | - 'returnto' => $_SERVER['SCRIPT_NAME'], |
811 | | - 'returntoquery' => http_build_query( $_GET ), |
812 | | - ); |
813 | | - $p = http_build_query( $p ); |
814 | | - return kfTag( |
| 810 | + return '<span class="tsint-dashboardbacklink">' . TsIntuitionUtil::tag( |
815 | 811 | $text, |
816 | 812 | 'a', |
817 | 813 | array( |
818 | | - 'href' => "{$this->dashboardHome}?$p", |
| 814 | + 'href' => $this->getDashboardReturnToUrl(), |
819 | 815 | 'title' => $this->msg( 'bl-changelanguage', 'tsintuition' ), |
820 | 816 | ) |
821 | | - ); |
| 817 | + ) . '</span>'; |
822 | 818 | } |
823 | 819 | |
824 | | - public function showPromo(){ |
825 | | - // http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Wikimedia_Community_Logo-Toolserver.svg/21px-Wikimedia_Community_Logo-Toolserver.svg.png |
| 820 | + /** |
| 821 | + * Show a promobox on the bottom of your tool. |
| 822 | + * |
| 823 | + * @param $imgSize integer (optional) Defaults to 28px. |
| 824 | + * If 0 or a non-integer the image will be hidden. |
| 825 | + * @return The HTML for the promo box. |
| 826 | + */ |
| 827 | + public function getPromoBox( $imgSize = 28 ) { |
| 828 | + if ( is_int( $imgSize ) && $imgSize > 0 ) { |
| 829 | + $src = 'http://upload.wikimedia.org/wikipedia/commons/thumb/b/be' |
| 830 | + . '/Wikimedia_Community_Logo-Toolserver.svg' |
| 831 | + . "/{$imgSize}px-Wikimedia_Community_Logo-Toolserver.svg.png"; |
| 832 | + $img = TsIntuitionUtil::tag( '', 'img', array( |
| 833 | + 'src' => $src, |
| 834 | + 'width' => $imgSize, |
| 835 | + 'height' => $imgSize, |
| 836 | + 'alt' => '', |
| 837 | + 'title' => '', |
| 838 | + 'class' => 'tsint-logo', |
| 839 | + ) ); |
| 840 | + } else { |
| 841 | + $img = ''; |
| 842 | + } |
| 843 | + $promoMsgOpts = array( |
| 844 | + 'domain' => 'tsintuition', |
| 845 | + 'escape' => 'html', |
| 846 | + 'raw-variables' => true, |
| 847 | + 'variables' => array( |
| 848 | + '<a href="http://translatewiki.net/">TranslateWiki</a>', |
| 849 | + '<a href="http://toolserver.org/~krinkle/TsIntuition/">Toolserver Intuition</a>' |
| 850 | + ), |
| 851 | + ); |
| 852 | + $powered = $this->msg( 'bl-promo', $promoMsgOpts ); |
| 853 | + $change = $this->msg( 'bl-changelanguage', 'tsintuition' ); |
| 854 | + return "<div id=\"tsint-promobox\"><a href=\"{$this->getDashboardReturnToUrl()}\">$img</a><p>$powered <a href=\"{$this->dashboardHome}\">$change</a></p></div>"; |
826 | 855 | |
827 | | - // bl-promo |
828 | | - // bl-changelanguage |
829 | | - return ''; |
| 856 | + // bl-promo, bl-changelanguage |
830 | 857 | } |
831 | 858 | |
| 859 | + public function getFooterLine(){ |
| 860 | + return $this->getPromoBox( 'no-image' ); |
| 861 | + } |
832 | 862 | |
| 863 | + |
833 | 864 | /* Other functions |
834 | 865 | * ------------------------------------------------- */ |
835 | 866 | |
— | — | @@ -866,6 +897,26 @@ |
867 | 898 | } |
868 | 899 | |
869 | 900 | /** |
| 901 | + * Build a permalink to the dashboard with a returnto query |
| 902 | + * to return to the current page. To be used in other tools. |
| 903 | + * |
| 904 | + * @example: |
| 905 | + * Location: http://toolserver.org/~foo/JohnDoe.php?wiki=loremwiki_p |
| 906 | + * HTML: |
| 907 | + * '<p>Change the settings <a href="' . $I18N->getDashboardReturnToUrl() . '">here</a>'; |
| 908 | + * |
| 909 | + * |
| 910 | + */ |
| 911 | + public function getDashboardReturnToUrl() { |
| 912 | + $p = array( |
| 913 | + 'returnto' => $_SERVER['SCRIPT_NAME'], |
| 914 | + 'returntoquery' => http_build_query( $_GET ), |
| 915 | + ); |
| 916 | + $p = http_build_query( $p ); |
| 917 | + return "{$this->dashboardHome}?$p"; |
| 918 | + } |
| 919 | + |
| 920 | + /** |
870 | 921 | * Get a localized date. Pass a format, time or both. |
871 | 922 | * Defaults to the current timestamp in the language's default date format. |
872 | 923 | * |
Index: trunk/tools/ToolserverI18N/public_html/index.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | $returnTo = $kgReq->getVal( 'returnto' ); |
111 | 111 | $returnToQuery = $kgReq->getVal( 'returntoquery' ); |
112 | 112 | if ( TsIntuitionUtil::nonEmptyStr( $returnTo ) ) { |
113 | | - if ( !TsIntuitionUtil::nonEmptyStr( $returnToQuery ) ) { |
| 113 | + if ( TsIntuitionUtil::nonEmptyStr( $returnToQuery ) ) { |
114 | 114 | $returnToQuery = '?' . urldecode( $returnToQuery ); |
115 | 115 | } else { |
116 | 116 | $returnToQuery = ''; |
Index: trunk/tools/ToolserverI18N/language/messages/Monumentsapi.i18n.php |
— | — | @@ -0,0 +1,36 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Interface messages for tool "MonumentsAPI". |
| 5 | + * |
| 6 | + * @toolowner p_erfgoed |
| 7 | + */ |
| 8 | + |
| 9 | +$url = '~erfgoed/api/'; |
| 10 | + |
| 11 | +/** |
| 12 | + * English |
| 13 | + * |
| 14 | + * @author Multichill |
| 15 | + */ |
| 16 | +$messages['en'] = array( |
| 17 | + 'title' => 'Monuments API', // Do not translate |
| 18 | + 'search-table-th-field' => 'Field', |
| 19 | +); |
| 20 | + |
| 21 | +/** |
| 22 | + * Documentation |
| 23 | + * |
| 24 | + * @author Krinkle |
| 25 | + */ |
| 26 | +$messages['qqq'] = array( |
| 27 | + 'title' => "{{Notranslate}}\n\nThe title of the tool.", |
| 28 | +); |
| 29 | + |
| 30 | +/** |
| 31 | + * Nederlands |
| 32 | + * |
| 33 | + * @author Krinkle |
| 34 | + */ |
| 35 | +$messages['nl'] = array( |
| 36 | + 'search-table-th-field' => 'Veld', |
| 37 | +); |
Property changes on: trunk/tools/ToolserverI18N/language/messages/Monumentsapi.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 38 | + native |
Index: trunk/tools/ToolserverI18N/language/messages/Tsintuition.i18n.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | 'renewcookies-success' => 'Cookies vernieuwd! Je bent weer helemaal gereed voor de komende $1.', |
66 | 66 | 'tab-overview' => 'Overzicht', |
67 | 67 | 'tab-settings' => 'Verander instellingen', |
| 68 | + 'bl-mysettings' => 'Mijn taalinstellingen', |
68 | 69 | ); |
69 | 70 | |
70 | 71 | /** |
Index: trunk/tools/ToolserverI18N/language/Fallbacks.php |
— | — | @@ -20,4 +20,6 @@ |
21 | 21 | 'fy' => 'nl', |
22 | 22 | |
23 | 23 | 'nds' => 'de', |
| 24 | + |
| 25 | + 'os' => 'ru', |
24 | 26 | ); |
Index: trunk/tools/ToolserverI18N/TsIntuitionUtil.php |
— | — | @@ -90,4 +90,36 @@ |
91 | 91 | return $dump; |
92 | 92 | } |
93 | 93 | |
| 94 | + |
| 95 | + /* Primitive html building */ |
| 96 | + /* Based on kfTag from the BaseTool class */ |
| 97 | + function tag( $str, $wrapTag = 0, $attributes = array() ) { |
| 98 | + $selfclose = array( 'link', 'input', 'br', 'img' ); |
| 99 | + |
| 100 | + if ( is_string( $str ) ) { |
| 101 | + if ( is_string( $wrapTag ) ) { |
| 102 | + $wrapTag = trim( strtolower( $wrapTag ) ); |
| 103 | + $attrString = ''; |
| 104 | + if ( is_array ( $attributes ) ) { |
| 105 | + foreach ( $attributes as $attrKey => $attrVal ) { |
| 106 | + $attrKey = htmlspecialchars( trim( strtolower( $attrKey ) ), ENT_QUOTES); |
| 107 | + $attrVal = htmlspecialchars( trim( $attrVal ), ENT_QUOTES); |
| 108 | + $attrString .= " $attrKey=\"$attrVal\""; |
| 109 | + } |
| 110 | + } |
| 111 | + $return = "<$wrapTag$attrString"; |
| 112 | + if ( in_array( $wrapTag, $selfclose ) ) { |
| 113 | + $return .= '/>'; |
| 114 | + } else { |
| 115 | + $return .= ">" . htmlspecialchars( $str ) ."</$wrapTag>"; |
| 116 | + } |
| 117 | + } else { |
| 118 | + $return = $str; |
| 119 | + } |
| 120 | + return $return; |
| 121 | + } else { |
| 122 | + return ''; |
| 123 | + } |
| 124 | + } |
| 125 | + |
94 | 126 | } |