I cannot fully translate the labels for the results, because these consist partially of the raw (and English) operator names. In other words, when building a Dutch website, the first free column uses the label "Pagina COUNT" instead of "Paginatotaal", and so on.
I studied theme.inc to find out how to create a patch, but was stymied by for instance the use of a dollar operator (I assume it's an operator) on line 178 ("foreach ($$process as $num => $row)"). It also seems to me that if this bug were to be fixed, you'd probably want to have a table somewhere that translates operator types to (human readable) operator names, and make it so that users can change these labels in the admin interface.
Another solution that would work for me would be if you could just change the label in the view.
Some tags to help find this issue: localization, translation.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | translate_operation-5.patch | 770 bytes | mgifford |
| #3 | translate_operation.patch | 799 bytes | ts145nera |
Comments
Comment #1
ndvo commentedThe problem is that the operation labels are not ready for translation and also not being used on display.
You will need to edit two files to get it fixed: views_calc.module and theme.inc, both are in the views_calc folder. The function _views_calc_calc_options sets the available operation options, but it does not use the t() (translation) function on the labels.
On the file views_calc.module, line 55 (this line may be different on your version), edit the returned array so to use the translation function on the labels, as seen bellow:
Now, on the themes.inc files we will need it to use the label instead of the operation name on display. The operation name is on the key element of the array and the label is on the value. So we will capture the options on a variable and call the value of the operation key. Just edit themes.inc starting on line 202 (the line number may be different on your version):
The code with the problem looks like this:
You should edit it to look like this:
After that you will be able to translate it using the Drupal interface. Note that to translate the sentence you will need to translate the string "Total !Calculation" AND you will also need to translate the label of the operations "Sum", "Avarage", etc.
In my case "Total !Calculation" became "!Calculation total" and "Sum" became "Soma", in order to obtain "Soma total".
Comment #2
karens commentedThe D6 version is no longer supported.
Comment #3
ts145nera commentedHi,
I've made this patch for D7 (7.x-1.0+9-dev) I hope this is usefull for you.
Bye
Comment #4
magnus commentedComment #5
mgiffordNo longer applies.
Is this a user provided string? If so https://openconcept.ca/blog/matt/translating-user-entered-strings-d7
Comment #6
mgiffordThis is just a re-roll of #3. The patch wasn't rolled against the git version of the repo. Should be easier to apply/test now.
I didn't use i18n_string() in the patch but still think this is a user defined variable, so probably should be done this way. Just don't see where the language is presently exposed.
Comment #7
giupenni commentedPatch #6 works for me.