Closed (fixed)
Project:
Privatemsg
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Feb 2010 at 21:28 UTC
Updated:
26 May 2011 at 13:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
berdirPatch is based on #292634-20: confirmation emails not in the right language and http://drupal.org/node/609364
Comment #2
miro_dietikerThat's great.
In admin case we should only rely on variable_set and variable_get for presentation. Calling tt() is great to create the string in text group, but the return value should never be considered for presentation / output. Else we might overwrite the variable (default language representation) with a translation just because of a language switch. If switched the system into default language -- calling tt will (usually) refuse translating default language and provides now the wrongly translated (overwritten) value.
One option would be to add $translate which can disable translation in case of FALSE:
function _pm_email_notify_text($key, $translate=TRUE, $language = NULL) {
So: In admin case we should get plain original text via variable_get inside notify_text -- no tt for return value in any case. However we should still call tt() in this case to make sure the item is added to interface translation.
So admin settings can only update the variable, not the translations.
Comment #3
berdirRerolling the patch
- Added the $translate flag
- Since the main issue is imho not a technical one but the problem that admins insert translated text (works only when you're site is in a single language) when they shouldn't, I've also extended the help text a bit.
Comment #4
miro_dietikerLooks much better now. I just can't believe the amount of potential issues this snippet has...
If you check calling _pm_email_notify_text you will notice that finally all calls of tt() will have $update=TRUE.
So the locale always enforces refresh in case of call via wrapper. This is bad and we might need another variable... or we can decide based on parm $translate.
Regarding hook_locale: Did you decide to implement it even if it seems to be removed in newer versions and doc is almost missing?
Many thanks for bringing translation wrapper issues forward!
Comment #5
YK85 commentedI was wondering if this patch allows the privatesmg notifiation email to be sent out based on the user's preferred language? If user has preferred language English=> receives english, if user has preferred language French=>receves in French. Where can this French message be typed?
Thank you!
Comment #6
berdirYeah, that patch fixes that. It was already possible before, but changing the original source string (usually english) would cause to loose all translations.
You can create translations of the mail texts through the Translate interface, that information/link is also displayed when applying the patch.
Comment #7
YK85 commentedthe patch at #3 works great! thanks
Comment #8
berdir- $update is now only set to TRUE if $translate is FALSE, because the source can only be updated through the settings page
- Improved apidocs
- Compatibility with i18nstrings.module v 1.3+ (Define in hook_locale that we don't use a format)
Comment #9
berdirFixed in 6.x-2.x-dev, this needs to be ported to 7.x.
Comment #10
miaoulafrite commentedHi there, thanks for this wonderful module
could somebody please tell me how to translate sent messages? so that the mail sent is sent considering the current language of the receiver?
thanks
Comment #11
BenK commentedSubscribing...
Comment #12
joostvdl commentedHow can this work? There is no where a function that first creates the i18nstring (with i18nstrings_update). Therefore are the strings not found in the database. Translating is not possible.
Comment #13
miro_dietikerjoostvdl - the api in i18n changed after this patch.
It worked before.
So we need to rewrite the code to use i18nstrings_update...
Comment #14
joostvdl commentedTo overcome the problem I created a patch to support the locale_refresh function. This is just a temporary solution, but works ;-)
Comment #15
berdirUpdating version.
The patch seems to be again a hacked version, I'm pretty sure that there are no dsm() calls in the original.
I guess it would make sense to create a separate function for the default string so that it doesn't need to be repeated.
Also, I assume it is necessary to call the update functions when submitting the settings form?
Comment #16
berdirComment #17
joostvdl commentedOops... hereby the patch against the 6.x-2.x-dev version
Comment #18
berdirComment #19
berdirYou need to create the patch from the privatemsg top-level directory, so that the path is pm_email_notify/pm_email_notify.module
A short docblock would be nice.
See above, we should move the default-handling from _pm_email_notify_text() into a separate function and then just call it here. Note that we imho need to insert the actual configured value, not the original.
And additionally, update it when the settings are saved.
Powered by Dreditor.
Comment #20
berdirCommited an improved version of the patch from #17. Back to 7.x-2.x
Comment #21
berdirPorted and commited to 7.x-2.x