I couldn't get it to translate the default entry nor a custom one. I also tried changing line 105 in nodeformsettings.module from:

'#default_value' => variable_get('nodeformsettings_submit_'. $form['#node_type']->type, 'Save'),

to

'#default_value' => variable_get('nodeformsettings_submit_'. $form['#node_type']->type, t("Save")),

But the string remained untranslated. Any ideas why this may be happening?

Thanks for such a useful module btw!

Comments

lelizondo’s picture

Status: Active » Fixed

commited

dddave’s picture

Title: Submit button text not translatable » Make Submit button text translatable
Category: bug » task
Status: Fixed » Active

This doesn't seemed to be fixed. Could be because the OP did not offer something committable. ;)

Played quite a while with this feature but wasn't able to succeed.

lelizondo’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

I didn't actually tried installing other language to see if it was working, I just applied the change.

Did you try the dev version?

castawaybcn’s picture

Sorry if my initial post led you to believe that there was a solution there.
What I actually meant is that I tried something and did not work, so I am also quite surprised to see my unsuccessful attempt commited...

lelizondo’s picture

Category: task » bug

Ok, now I get it, I saw just the two lines of code and thought that I forgot to make 'Save' translatable.

I'll look into it to see what's causing the bug.

lelizondo’s picture

Status: Active » Fixed

The problem has been solved. For reference, the correct way to translate a string with a variable_get is to wrap the variable_get function inside the t() function.

Take a look at #611492: String is untranslatable: variable_get need to be wrapped by t function

Please close #696332: Save button on comments broken if it solves itself, I didn't have any problem.

castawaybcn’s picture

thanks so much for the fix and the (very) useful information!

dddave’s picture

Perhaps a hint could be added about how to properly translate the button text. I would guess that most people try to enter different texts into the 'button text' field for each language they use. They could use a hint that they have to use the i18n translation feature.

dddave’s picture

Status: Fixed » Active

Sorry for reactivating but Drupal complains:

    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t(variable_get('commentformsettings_submit_'.$form['#node_type']->type,"Save")) in nodeformsettings.module on line 67. Read more at http://drupal.org/node/322732
    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t(variable_get('nodeformsettings_submit_'.$form['#node_type']->type,'Save')) in nodeformsettings.module on line 138. Read more at http://drupal.org/node/322732
    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t(variable_get('nodeformsettings_submit_'.$node->type,'')) in nodeformsettings.module on line 241. Read more at http://drupal.org/node/322732
    * The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t(variable_get('commentformsettings_submit_'.$node->type,"Save")) in nodeformsettings.module on line 312. Read more at http://drupal.org/node/322732
lelizondo’s picture

I don't know how to solve this, I'll take a look in the forums to see what can I find. My guess is you'll have to translate only the default value, in this case: 'Save', if I take the variable_get function out of the t() function, the string won't be translated.

I'll try to translate this module to spanish to replicate the problem.

dddave’s picture

Argh! This translation stuff makes my head explode. I had one of my content types I am using for testing already with a translated submit button. So unless you stumble upon some codestyle errors or some t() rules this can be set to fixed again.

lelizondo’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

Gabriel R.’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new8.92 KB

@castawaybcn in OP: That's not where you want to add the t(). I notice that the current version module currently has your change implemented, which is not a good idea IMHO.

Instead, the t() should be added to where the strings are being displayed.

See the attached file. Roll your own patch.

Gabriel R.’s picture

StatusFileSize
new2.5 KB

And here's a patch, I hope it's right.

lelizondo’s picture

Status: Needs review » Patch (to be ported)

Thanks, I'll commit soon

skizzo’s picture

patch fails to apply to current 6.x-1.x-dev version (2010-07-11)
or has it been already committed ???

lelizondo’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Patch (to be ported) » Fixed

fixed in 6.x-2.x

reopen if necessary

Status: Fixed » Closed (fixed)

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