Comments

jmiccolis’s picture

Version: 5.x-1.x-dev » master

Bumping version to HEAD, as this is something I'd like to see addressed.

artol’s picture

Update table strings in casetracker_case_states. Chears, Arto

boobaa’s picture

Title: How to translate case state? » Make case states translatable
Version: master » 6.x-1.0-beta4
Component: User interface » Code
Category: support » feature
Status: Active » Needs review
StatusFileSize
new3.06 KB

Please find the attached patch, which makes use of i18nstrings.module (if available) to make Case Tracker states translatable. (This is the first time I make strings translatable, so please correct me if I was following Making your custom data translatable the wrong way.)

boobaa’s picture

Previous patch had a bug: with that one there were wrong locale locations in the DB. Now this rerolled one has removed this bug, and it even has "refresh" capability.

boobaa’s picture

Sorry for submitting a git patch - I'm not too used to ancient things like cvs. Attaching a "proper" cvs patch now.

svendecabooter’s picture

Patch in #5 works as advertised.
That seems like the best approach as far as I can tell.

jose reyero’s picture

Status: Needs review » Needs work

The patch looks good. Just some tips:

- Instead of module_exists('i18nstrings') it's easier to implement some module's wrapper like

function casetracker_tt() {}

Read about this here: http://drupal.org/node/609364

- The hook_locale($op = 'refresh') is deprecated, not needed anymore

- Maybe you'd save some code and improve performance by making the casetracker_realm_load() and/or casetracker_case_state_load() return the translated names. You can do it either by passing a $translate parameter or by adding a new property. I.e.

function casetracker_case_state_load($csid = NULL, $realm = NULL, $reset = FALSE) {
  static $states_lookup;

  if (!$states_lookup || $reset) {
....
    while ($row = db_fetch_object($results)) {
      $row->display = casetracker_tt("casetracker:$row->realm:$row->csid:name", $row->name);
      $states_lookup[$row->realm][$row->csid] = $states_lookup['all'][$row->csid] = $row;
    }
  }
  ....
}
// Then you can use 'display' property instead of 'name' for printing out the value
boobaa’s picture

Status: Needs work » Needs review
StatusFileSize
new3.38 KB

Reworked the patch following Jose's advices above.

jose reyero’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.78 KB

This latest one looks great. Just added some minor improvements:

- The textgroup 'casetracker' can be added by casetracker_tt(), will save some text
- The same function can be used too for casetracker_state_save(), saving some code
- The string id namespace: "[realm]:[csid]" replaced by "case_states:[csid]" (This is to avoid clashes in the future in case you have other types of objects translatable in this module, and other realms)

Re-rolled and tested. It works for the basic case of state names translation though may use some improvements in the future (translate other stuff, take a language parameter for cron/mails, etc, etc...)

svendecabooter’s picture

That works like a charm Jose

castawaybcn’s picture

works great for me too, thanks!

jmiccolis’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all, this is committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jose reyero’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.95 KB

This is an update for the latest i18nstrings (6.x-1.3) changes.

Right now it still works though it is using an obsoleted API, soon to be dropped.

jmiccolis’s picture

Status: Needs review » Fixed

Thanks Jose, this has been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sepla’s picture

Subscribing.