I use plain text as well as patterns to create the node title, for example my pattern is Customer - [field_fullname-raw], [field_country-raw].
I would like this to be Kunders - [field_fullname-raw], [field_country-raw] if the node language is Swedish.

Is there some way I can do this? Thanks.

Comments

aufumy’s picture

what is 'Customers' is it text from the body, or is it something else?

tomsm’s picture

I have a similar problem.
I have a content type called "Order". The automatic title is [type-name] [author-name] [dd]/[mm]/[yyyy].

I have translated the name of the content type "Order" (type:order:name) in French and Dutch, but when I create a node in these languages the [type-name] token is not translated.

I think this is a token, i18n issue.

peacog’s picture

'Customers' is not text from the body. I enter it directly into the Pattern for the title field in the Automatic title generation section of my content type.

aufumy’s picture

I believe that you have to use the PHP option

"Evaluate PHP in pattern."

echo (t('Customer') . ' - [field_fullname-raw], [field_country-raw]');

Not sure if the echo() is needed or not.

peacog’s picture

Thank you for the suggestion. I tried it but I'm afraid it didn't work. I could not add translations for the word Customer in www.example.com/admin/build/translate/search. The search did not find the string. I also substituted a string that already has a translation in the Translation interface, but that didn't work either.

blueblade’s picture

i have the same problem...

odisei’s picture

The same problem

mairav’s picture

I also need this, have any of you found a solution?

mairav’s picture

Any help about this?

colan’s picture

Subscribing.

alonpeer’s picture

Status: Active » Needs work

PHP evaluation can work, if the order of token and PHP evaluation will be switched.
In the function _auto_nodetitle_patternprocessor(), first the tokens are replaced, and only then the PHP is evaluated. If the order between them is switched, then titles such as the following will be evaluated correctly:

<?php
  return t('Customer - [field_fullname-raw], [field_country-raw]');
?>
aufumy’s picture

Status: Needs work » Fixed

Or use the node object.

echo t('Customer - @fullname, @country', array('@fullname' => $node->field_fullname[0]['value'], '@country' => $node->field_country[0]['value']));

Status: Fixed » Closed (fixed)

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

bisonbleu’s picture

I need some help. What I'm trying to translate is the term Registration. The token [field_formsaisreg_joueur-title] refers to the full name of a person (e.g. John Smith). I used #12 this way.

<?php
echo t('Registration @playername', array('@playername' => $node->field_formsaisreg_joueur-title[0]['value']));
?>

and got one amazing title...

Parse error: syntax error, unexpected '[', expecting ')' in /home/renaudj/public_html/drpl1/sites/all/modules/auto_nodetitle/auto_nodetitle.module(254) : eval()'d code on line 2

What did I do wrong?

Original ANT pattern is Registration [field_formsaisreg_joueur-title], where [field_formsaisreg_joueur-title] is a cck node reference (select list widget) where "-title" points to a player's name (a node title).