Index: trunk/extensions/Translate/scripts/fuzzy.php |
— | — | @@ -79,14 +79,6 @@ |
80 | 80 | */ |
81 | 81 | public function __construct( $titles ) { |
82 | 82 | $this->titles = $titles; |
83 | | - |
84 | | - global $wgTranslateFuzzyBotName; |
85 | | - |
86 | | - if ( !isset( $wgTranslateFuzzyBotName ) ) { |
87 | | - STDERR( "\$wgTranslateFuzzyBotName is not set" ); |
88 | | - return; |
89 | | - } |
90 | | - |
91 | 83 | $this->allclear = true; |
92 | 84 | } |
93 | 85 | |
— | — | @@ -111,27 +103,31 @@ |
112 | 104 | global $wgTranslateMessageNamespaces; |
113 | 105 | $dbr = wfGetDB( DB_SLAVE ); |
114 | 106 | |
115 | | - $search_titles = array(); |
| 107 | + $search = array(); |
116 | 108 | foreach ( $this->titles as $title ) { |
117 | | - $title = TranslateUtils::title( $title, '' ); |
118 | | - $title = str_replace( ' ', '_', $title ); |
119 | | - $search_titles[] = 'page_title ' . $dbr->buildLike( $title, $dbr->anyString() ); |
| 109 | + $title = Title::newFromText( $title ); |
| 110 | + $ns = $title->getNamespace(); |
| 111 | + if ( !isset( $search[$ns] ) ) $search[$ns] = array(); |
| 112 | + $search[$ns][] = 'page_title' . $dbr->buildLike( $title->getDBKey(), $dbr->anyString() ); |
120 | 113 | } |
121 | 114 | |
122 | | - $condArray = array( |
123 | | - 'page_is_redirect' => 0, |
124 | | - 'page_namespace' => $wgTranslateMessageNamespaces, |
| 115 | + $title_conds = array(); |
| 116 | + foreach ( $search as $ns => $names ) { |
| 117 | + if ( $ns == NS_MAIN ) $ns = $wgTranslateMessageNamespaces; |
| 118 | + $titles = $dbr->makeList( $names, LIST_OR ); |
| 119 | + $title_conds[] = $dbr->makeList( array( 'page_namespace' => $ns, $titles ), LIST_AND ); |
| 120 | + } |
| 121 | + |
| 122 | + $conds = array( |
125 | 123 | 'page_latest=rev_id', |
126 | 124 | 'rev_text_id=old_id', |
127 | | - $dbr->makeList( $search_titles, LIST_OR ), |
| 125 | + $dbr->makeList( $title_conds, LIST_OR ), |
128 | 126 | ); |
129 | 127 | |
130 | 128 | if ( count( $this->skipLanguages ) ) { |
131 | | - $condArray[] = 'substring_index(page_title, \'/\', -1) NOT IN (' . $dbr->makeList( $this->skipLanguages ) . ')'; |
| 129 | + $conds = 'substring_index(page_title, \'/\', -1) NOT IN (' . $dbr->makeList( $this->skipLanguages ) . ')'; |
132 | 130 | } |
133 | 131 | |
134 | | - $conds = $dbr->makeList( $condArray, LIST_AND ); |
135 | | - |
136 | 132 | $rows = $dbr->select( |
137 | 133 | array( 'page', 'revision', 'text' ), |
138 | 134 | array( 'page_title', 'page_namespace', 'old_text', 'old_flags' ), |
Index: trunk/extensions/Translate/README |
— | — | @@ -29,6 +29,8 @@ |
30 | 30 | http://translatewiki.net/docs/Translate/html/ |
31 | 31 | |
32 | 32 | == Change log == |
| 33 | +* 2011-11-04 |
| 34 | +- fuzzy.php can now take optional namespace prefix for each message |
33 | 35 | * 2011-10-30 |
34 | 36 | - The script referenced at 2011-08-26 is now included in the source |
35 | 37 | - Fixed compatibility with MW 1.17 |