['r4032login_display_denied_message'] default_value not translatable

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Thomas_Zahreddin’s picture

FileSize
1.43 KB

here's the patch

lotyrin’s picture

Title: translation of variable - values » Translation of variables
Assigned: Unassigned » lotyrin

This doesn't make any more sense than these variables do already. Such a strategy would only work with a single site language.

What needs to happen here is either:

Document that if these strings are to be translated, the user needs to have i18n's variable translation working, and ensure that r4032login supports it's variables to be translated by i18n.

OR make these strings static and the user uses normal string translation UI to translate (or override) these strings.

I lean toward the latter, but the former is closer to what we're already doing, so I'll look into making sure that it works.

Thomas_Zahreddin’s picture

i don't understand what is wrong to have the default string translateable.

if the default string is not changed, then it can be translated for each language the site uses, with no additional modules.

In the moment only one language is possible for the strings, since the variable can store only one value and is not passed throug t().

And using the default value with the default translation also saves one extra configuration step.

lotyrin’s picture

Title: Translation of variables » Integrate with i18n_variable

I guess I hadn't thought that through.

I've just committed adding t() to these. Integration with i18n_variable remains open.

f0ns’s picture

Issue summary: View changes

Did not integrate this with i18n variable, I just made the config form hidden under website information and changed this in function r4032login_redirect():

if (variable_get('r4032login_display_denied_message', TRUE) && empty($_POST)) {
      $message = t('Access denied. You must log in to view this page.');
      drupal_set_message($message, 'error');
    }

Now I can easily translate the error message with translate interface.

NWOM’s picture

Version: 6.x-1.x-dev » 7.x-1.8

Has there been any work done on this for Drupal 7? Thanks in advanced.

dshields’s picture

FileSize
870 bytes

This patch seems to get the job done. Save your string in Site Information, visit a page as an anonymous user that you should not have access to, then add the translation via the translate interface.

mgifford’s picture

@dshields - Thanks! This will definitely work.

Would be better though to go with the i18n_string() approach defined in this blog post. I think this would look like:

if(function_exists('i18n_string')) {
  drupal_set_message(filter_xss_admin(i18n_string('r4032login:customized user message', $message)), $message_type);
} 
else {
  drupal_set_message(filter_xss_admin($message), $message_type);
}

But I haven't actually done this yet.

dshields’s picture

Status: Active » Needs review
Issue tags: +i18n
FileSize
942 bytes

Thanks for the tip, mgifford and mparker17 for the blog post. How does this look?

mgifford’s picture

That patch was failing here:
http://simplytest.me/project/r4032login/7.x-1.8?patch[]=https://www.drup...

I applied it against the git repo and got "patch unexpectedly ends in middle of line" so just rerolled it. It works here:

http://simplytest.me/project/r4032login/7.x-1.8?patch[]=https://www.drup...

mgifford’s picture

I see Site name & Slogan as clearly "This is a multilingual variable." but not for the User login 'access denied' message here:

/admin/config/system/site-information%3Fvariable_realm_key_language%3Daf

I applied the patch, set up the i18n & Variable modules. Not sure what the problem is.

Do I need to set up anything else to enable this?

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

This looks like it is working.

lotyrin’s picture

Assigned: lotyrin » Unassigned
Status: Reviewed & tested by the community » Needs work

No, integration with i18n_string isn't what we want here. The default value is a UI string, should be translated with t(). The variable is a variable, so we'll make it translate as via i18n_variable.

lotyrin’s picture

Status: Needs work » Closed (works as designed)

Just verified but, this already works. Has for a long time.

Here's the howto: https://www.drupal.org/node/1113374

dshields’s picture

While I see that i18_string translation is not the approach we're going for here, i do not see how "this already works"