0

I have a JQGrid table that can be displayed in different languages. The data for this table is stored as English text and translated when output. The JQGrid table can be filtered by text.

The issue I have, is that when the JQGrid table is filtered, the query will run against the English text. E.g.

Original table: Yes No

Translated table: Oui Non

User is French and tries to filter for 'Oui': Database query will return zero results because 'Oui' does not exist in the database table. If the French user queries for 'Yes' then Oui will show because it matches the database and is translated on output.

This is using custom integration with JQGrid.

Since all string translation is cached and as far as I know there are no database tables available to join on, how can I get translated filtering to work?

Any ideas on the best way to handle this?

0

Ok. I've solved this in what I believe is a reasonable way but it won't really scale:

As I build up the data for the table and translate each cell, I store that into an array with the foreign language string as the key and the untranslated string as the value. (This could work either way round).

$strings[t($my_string)] = $my_string;

I save that array after I've done everything with the last snippet. This array is read at the beginning of loading the table data:

$strings = $saved_strings = variable_get('my_translated_strings_' . $language->language, array());

If the array has changed then I will save it:

if ($strings != $saved_strings) {
  variable_set('my_translated_strings_' . $language->language, $strings);
}

I can then manipulate the filter rules to filter on the original untranslated strings instead of the user's language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.