New status filter for plural

claudiu.cristea - October 15, 2009 - 11:55
Project:Localization server
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:claudiu.cristea
Status:needs review
Description

Sometimes we want to see only translations with plurals.

This patch add a new status filter that add the ability to show all translations that have plural.

AttachmentSize
l10n_server_plural_filter-D6.patch3.76 KB

#1

Gábor Hojtsy - October 15, 2009 - 22:52
Status:needs review» needs work

+++ l10n_community/translate.inc 15 Oct 2009 11:47:23 -0000
@@ -693,7 +704,13 @@ function l10n_community_get_strings($lan
+  if ($filters['status'] & L10N_STATUS_HAS_PLURAL) {
+    $where[] = "LOCATE(CHAR(0), s.value) > 0";
+  }
+  elseif ($filters['status'] & L10N_STATUS_NO_PLURAL) {
+    $where[] = "LOCATE(CHAR(0), s.value) = 0";
+  }

This code fragment pretty much shows why this approach fails badly. If we use LOCATE(), the database will need to run this function on each row, which prohibits using any indexes.

I'd say we'd rather cache this data in a column and do this calculation only once when the source string is inserted into the database.

This review is powered by Dreditor.

#2

claudiu.cristea - October 16, 2009 - 05:35

That was my first thought but I didn't want to alter the table structure...

#3

claudiu.cristea - October 16, 2009 - 06:34
Status:needs work» needs review

Here's a patch reflecting #1.

AttachmentSize
l10n_server_plural_filter1-D6.patch 4.92 KB

#4

claudiu.cristea - October 16, 2009 - 06:51

The above patch is incomplete... Use this one.

AttachmentSize
l10n_server_plural_filter2-D6.patch 6.24 KB

#5

claudiu.cristea - October 16, 2009 - 07:31

Added also filtering on the moderation page.

AttachmentSize
l10n_server_plural_filter3-D6.patch 7.23 KB

#6

Gábor Hojtsy - October 16, 2009 - 08:47
Status:needs review» needs work

Much better direction IMHO! The patch does not add the field to fresh installs though.

#7

claudiu.cristea - October 16, 2009 - 09:28

You're right. Here's the fix...

AttachmentSize
l10n_server_plural_filter4-D6.patch 7.73 KB

#8

claudiu.cristea - October 16, 2009 - 09:29
Status:needs work» needs review

Forgot the the ticket status...

#9

podarok - October 17, 2009 - 08:35

subscribe

 
 

Drupal is a registered trademark of Dries Buytaert.