1

Short: How can I import .po file having dynamic variables in strings like follows

$message = t('Hi @firstname, please follow @sitelink or mail me at @email ', $var);

Indetail:

I've written a custom module to send mail notification to users. In that module $message string has dynamic variables like follows (sample)

$var = array('@firstname' => $username, '@sitelink' => $GLOBALS['base_url'], @email => $email);  
$message = t('Hi @firstname, please follow @sitelink or mail me at @email ', $var);

How can I import $message string to my site.

I could translate all the static strings to Spanish of other custom modules like follows.

#: mycustom.module
msgid "Are you sure to approve"
msgstr "¿estás seguro de aprobar"

But how can I write the same for Dynamic variables. Right now Spanish Users are getting their mail in English?

Note: I'm just using Drupal core Locale module.

1
  • Which is kinda sad because it's such a well written question :( – Letharion Dec 19 '14 at 8:40
0

There are two way to achieve this

Add string in a your .po file like follows

msgid "Hi @firstname, please follow @sitelink or mail me at @email"
msgstr "Hola @firstname, por favor, siga @sitelink o envía un email al @email"

and import that .po file by going

Administration » Configuration » Regional and language » Translate interface » Import

enter image description here If you want to change individual translated strings go to

Home » Administration » Configuration » Regional and language » Translate interface » Translate

You can find list of strings there each having edit link beside. So you change the individuals like follows.

enter image description here

Hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.