Download & Extend

Contact categories can't be translated with i18n

Project:Drupal core
Version:7.x-dev
Component:contact.module
Category:bug report
Priority:normal
Assigned:Dave Reid
Status:closed (fixed)

Issue Summary

The contact module stores all the contact categories in a separate table and do not use the t() function for displaying these, which means there is no way to translate the labels. I have two patches doing two different things:

- contact_i18n_t.patch ; use the t() function when displaying categories labels, these can then be translated through the locale module.

- contact_i18n_variable.patch ; store categories in a variable, thus enabling to set it as an i18n variable (in settings.php). This may be interesting to allow different email addresses for different languages (inquiry@company.com for the English version and inquiry@company.cn for the Chinese version for example).

AttachmentSizeStatusTest resultOperations
contact_i18n_t.patch604 bytesIdleFailed: Failed to apply patch.View details
contact_i18n_variable.patch9.69 KBIdleFailed: Failed to apply patch.View details

Comments

#1

Could you make these patches (or a module that works like the patches) for D6? It would be very useful.

#2

subscribe

#3

Version:5.7» 7.x-dev

Feature requests are only accepted in HEAD. Any bugfixes must also be fixed in HEAD first, then backported.

#4

subscribe

#5

I much prefer just using t() rather than dropping the whole table to use variables. Drupal core already uses t() with non-strings quite often (see http://localize.drupal.org/translate/projects/drupal/warnings).

Since this doesn't break existing translations, we should backport this to D6.

#6

Status:needs work» needs review

Patch attached for review.

AttachmentSizeStatusTest resultOperations
251482-contact-category-translate-D7.patch1.58 KBIdleFailed: Failed to apply patch.View details

#7

Assigned to:Anonymous» Dave Reid

#8

Category:feature request» bug report

I'd classify this as a bug report since this doesn't work properly without the patch and there's no way to override the strings.

#9

Rerolled for latest changes.

AttachmentSizeStatusTest resultOperations
251482-contact-category-translate-D7.patch1.6 KBIdlePassed: 13709 passes, 0 fails, 0 exceptionsView details

#10

Tested with russian language, little bit confused after entering russian category I found it's string at admin/config/regional/translate/translate

Reroll for current state, suppose there's should be a help text to point a user to write a category's name in english and then translate them at admin/config/regional/translate/translate
Maybe this should be displayed only if locale module enabled.

AttachmentSizeStatusTest resultOperations
251482-contact-category-translate-D7.patch1.42 KBIdlePassed: 13694 passes, 0 fails, 0 exceptionsView details

#11

We shouldn't have to explicitly say that something is translatable. Most users should assume that any kind of string is.

#12

Status:needs review» reviewed & tested by the community

Test this with a dummy contact.fr.po and it translated in both the site-wide contact form and the admin/structure/contact interface.

#13

Status:reviewed & tested by the community» needs work

Please note that #593746: Prepare Drupal core for dynamic data translation intends to make all of such loaded data throughout Drupal core translatable.

The approach taken here won't fly. t() must not be used on user-defined strings.

#14

@sun: This approach is consistently used throughout core. See http://localize.drupal.org/translate/projects/drupal/warnings

#15

uhm, you want to get approval for this patch by pointing to a page that lists warnings for improper usage of t() throughout Drupal core? ;)

#16

I make a patch to prepare http://drupal.org/node/593746#comment-2142776

@sun are you really sure that we could see in core #593746: Prepare Drupal core for dynamic data translation

This approach is great so i18n can translate the contact categories on-fly by rewriting queries, so I think that we should go with DBTNG

@Dave anyway i18n can translate categories if queries are completely overridable

AttachmentSizeStatusTest resultOperations
593746_contact.patch3.42 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 593746_contact_0.patch.View details

#17

Please upload a patch that can be run by the testbot (make sure it ends in 'd7.patch'.

#18

Status:needs work» needs review

Maybe just to change status...

#19

Some parts of patch already in, so changed a bit.

AttachmentSizeStatusTest resultOperations
593746_contact_d7.patch2.42 KBIdlePASSED: [[SimpleTest]]: [MySQL] 17,897 pass(es).View details

#20

+++ modules/contact/contact.admin.inc 17 Feb 2010 20:48:22 -0000
@@ -19,7 +19,14 @@ function contact_category_list() {
+    ->addTag('contact')

+++ modules/contact/contact.module 17 Feb 2010 20:48:23 -0000
@@ -159,7 +159,13 @@ function _contact_personal_tab_access(st
+    ->addTag('contact')

+++ modules/contact/contact.pages.inc 17 Feb 2010 20:48:23 -0000
@@ -27,6 +27,7 @@ function contact_site_form($form, &$form
+    ->addTag('contact')

I don't think that this tag makes any sense. Why did you add it?

Powered by Dreditor.

#21

@sun this tag is helpful for i18n to identify a query

#22

No, that's the 'translatable' tag ;)

#23

@sun Are you sure to remove this tags? They looks same as
http://api.drupal.org/api/function/_block_load_blocks/7

->addTag('block_load')

EDIT: You raise this at #46 #593746: Prepare Drupal core for dynamic data translation

#24

So here is a patch without this tag

AttachmentSizeStatusTest resultOperations
251482_contact_d7.patch1.69 KBIdlePASSED: [[SimpleTest]]: [MySQL] 17,892 pass(es).View details

#25

Status:needs review» reviewed & tested by the community

Thanks.

#26

bump :)

#27

Status:reviewed & tested by the community» fixed

Committed to CVS HEAD. Thanks.

#28

Status:fixed» closed (fixed)

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

#29

Version:7.x-dev» 6.x-dev
Status:closed (fixed)» patch (to be ported)

Can we backport this fix to D6?

#30

Version:6.x-dev» 7.x-dev
Status:patch (to be ported)» closed (fixed)

No, there is nothing to backport here.

#31

moonray there is multilingual contact form module for drupal6
just search for it

#32

I searched for it, only found tContact which does not help translating categories additionnal informations. I also tried with L10n without more luck. If someone has an easy solution, I'm a taker!

#33

For anybody looking for a solution, i18n_contact is in the Drupal 7 development version of the i18n module now, it translates contact categories, emails and autoreplies for you.