Ticket #666 (assigned defect)

Opened 1 year ago

Last modified 8 months ago

Translation2 doesn't handle case sensitive translation keys

Reported by: aj Assigned to: aj (accepted)
Priority: normal Milestone: 0.7.0
Component: SGL - Translation Severity: need feedback
Keywords: Cc: dmitri@telenet.lv

Description (Last modified by aj)

This is because the function in Translation2 that checks to see if the translation exists uses the query

"SELECT COUNT(*) FROM translation_en_iso_8859_15 WHERE page_id='edit'"

If it return 1 it updates instead of insert. The query

"SELECT COUNT(*) FROM translation_en_iso_8859_15 WHERE page_id='Edit'"

will also returns 1 if you have a row in the table with the page_id that is 'edit'

MySQL is not case sensative you need to use the BINARY option in the field definition

Change History

03/06/06 05:15:46 changed by aj

  • description changed.

03/06/06 05:30:47 changed by demian

  • owner changed from somebody to aj.
  • summary changed from Translation2 doesn't handle case senative translation keys to Translation2 doesn't handle case sensitive translation keys.
  • component changed from not categorised to SGL - Translation.
  • milestone deleted.

03/20/06 03:34:58 changed by aj

  • status changed from new to assigned.
  • milestone set to 0.6.0.

03/20/06 03:51:30 changed by aj

  • milestone changed from 0.6.0 to 0.7.0.

09/17/06 01:28:23 changed by aj

  • description changed.

09/21/06 11:15:08 changed by lakiboy

  • severity changed from not categorised to need feedback.

Hi guys!

This is pretty annoying. I can fix it, but how?

I think Demian said one day that all keywrods should be in lowercase. So should I convert all keywords to lower case?

09/21/06 11:30:40 changed by lakiboy

  • cc set to dmitri@telenet.lv.

Tickets #780 and #781 are related and I can handle them too. So I just neen a start point.

09/21/06 11:57:31 changed by lakiboy

As pointed by AJ a temporary solution is adding collate your_collation_here

     $queries[] = sprintf('CREATE TABLE %s ( '
                             .'%s VARCHAR(50) default NULL, '
                             .'%s TEXT NOT NULL collate utf8_bin, '
                             .'%s TEXT )',
                             $langData['table_name'],
                             $this->options['string_page_id_col'],
                             $this->options['string_id_col'],
                             $lang_col

directly in lib/PEAR/Translation2/Admin/Container/db.php to addLang() method. After that rebuild sgl.

09/22/06 08:11:56 changed by demian

hi Dmitri

Lorenzo is very responsive to suggestions, i have a feeling he would mod his t2 lib directly, anwyays, we don't want to modify pear libs as you know.

regarding LCing everything, this would kill all the translations and i'm sure it would take ages for folks to fix them, screw up the encoding again, etc. but agreed that all translations should be LCed ;-)

also, i haven't updated our repo to use latest t2 lib, we're 1 behind. can you or AJ advise me if latest t2 is ok to use?

10/11/06 16:13:14 changed by lakiboy

Hi Demian!

You probably saw Lorenzo's response about t2 improvements. In our case we'll never solve the problem. Only switching to MDB2 db driver we'll solve this ticket as I understood.

You already updated t2 lib and it's fine.

Should we close this ticket?

11/14/06 16:47:55 changed by quipo

Hi,

I've added the Translation2::setCharset() method (currently to the MDB2 driver only), so you can tell the db what charset you want the data back from your tables:

$tr->setCharset('utf8');

To create a new lang table with charset and collation info, you now can set them as addLang() options (2nd parameter):

$newLang = array(
    'lang_id'    => 'en',
    'table_name' => 'i18n',
    'name'       => 'english',
    'meta'       => 'some meta info',
    'error_text' => 'not available',
    'encoding'   => 'iso-8859-1',
);
$options = array(
    'charset'   => 'latin1',
    'collation' => 'latin1_bin',
);
$tr2->addLang($newLang, $options);

NB: this is only implemented in the MDB2 driver. MDB and DB are both deprecated and have no way to set the charset.

HTH