16

I have about 20 sites that have a common translation. I don't want to go into admin of each site each time the po-file is updated.

Is it possible to import a po-file using Drush?

25

I found a way to do this using Drush and Localization Update.

  1. Install Localization Update drush en l10n_update
  2. Configure a local path for po-files (admin/config/regional/language/update)
  3. Configure automatic updates from remote servers or just local sources

Now you can put your own po-files in a local path (for example sites/all/translations). If you have translations for your own module then you name it according to this naming convention:

modulename-version.language.po

So a Swedish po-file for 'my_module', version 7.x-1.1 would be named:

my_module-7.x-1.1.sv.po

Now you have everything setup and you can start updating your sites translation with Drush:

drush l10n-update-refresh # Looks for new po-files
drush l10n-update # Updates translations
  • I couldn't get this really work. I have exported the translations in a po-file using the UI. It was named as de.po for German. I've renamed it to my modules name and appended it the version of my module like: controller-7.x-1.0.de.po. Pushed it with git and executed the drush commands. But it doesn't detect my newly pushed po-file and says 'All translations up to date'. Where am I doing wrong? – Елин Й. Feb 13 '14 at 10:41
  • You need to place the po file in the directory configured by l10n_update as a source, typically sites/all/translations – FGM Feb 22 '14 at 9:23
  • 2
    Anyone knows how to do this in Drupal 8? – Guillaume Bois Sep 28 '16 at 18:44
  • Watch out! If you want to use this method for custom local modules, your .info file must have the project property, otherwise the module will be ignored completely. – thedotwriter Nov 20 '17 at 10:24
  • One last detail, with the 2.2 version, I had to specify --mode=overwrite when running drush l10n-update, otherwise the modifications in my .po file would not be taken into account (even if mode is already set to overwrite in the backend). – thedotwriter Nov 28 '17 at 10:23
3

At the moment there's no way to do it with Drush but you can use the Localization Update module.

You could also try using Selenium IDE or a Selenium script if you have a lot of sites. This is the best solution I was able to come up with for getting translations as an exportable.

  • I say there's no way to do it with Drush because I opened a feature request in the issue queue a few weeks ago and it was closed as "won't fix" with the reason that the maintainers think such a command should be tested in the i18n or other modules first before integrating it into the Drush trunk.
1

Also, the drush module Drush Language Commands has support for importing and exporting po files.

1

Your best bet is to use the Potx Exportables module.

It exposes Drush command drush potx-import-all

  • Welcome to Drupal Answers! Does the module have Drush support too? The OP is asking for a way to do it with Drush. – kiamlaluno Apr 19 '15 at 20:12
0

For those who lands here many years later, the same commands for Drush 9 are:

  1. drush locale:check
  2. drush locale:update

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.