Install and update translations in WordPress with Composer

Using Composer is a great way of organizing your WordPress project, with WordPress itself, plugins and themes declared as dependencies. However, an issue I’ve often seen is how you install translation files and keep them updated.

Koodimoonni’s repository

There is a very cool project by Koodimonni, who have created a Composer repository of some of the translation packs on Unfortunately this repository is limited to just 4 plugins, and the twenty* themes. This is close, but not enough. I could have forked that project and included more plugins and themes myself, but if people started using my repository, I would felt responsible for keeping it running too.

Angry Creative’s autodownloader

At the contributor day of WordCamp Stockholm 2017, the Swedish agency Angry Creative released a Composer package – Composer Auto Language Updates – that connects to the API at to download the translations for you. That is a great idea, and works with every plugin and theme hosted on!

Angry Creative’s package however has its quirks and in January I started fixing bits of it, and was 95% ready to make a pull request. However, life happened, and I forgot about it.

I forgot about Angry Creative’s package, until yesterday afternoon, when I randomly picked it up again. I still wasn’t happy with it – even with my contributions from January, so I started rewriting the whole thing as a Composer plugin. With a few hours today as well, I’ve managed to finish the rewrite, package it and release it so others can benefit from it.

Meet the Composer plugin wplang

Today I released the Composer package bjornjohansen/wplang. It is available on GitHub if you want to look at it, fork it or contribute to it. There are bits of Angry Creative’s original code and logic in there, so I kept the license as GPLv2+. It is also released on Packagist, so to install it you can just run a Composer command:

composer require bjornjohansen/wplang

To define which languages you want to download, and which directory to put your language files in, you have to add a small section in your composer.jsonfile:

"extra": {
    "wordpress-languages": [ "en_GB", "nb_NO", "sv_SE" ],
    "wordpress-language-dir": "wp-content/languages"

You should propbably want to customize these values to suit your needs.

Finally run:

composer update

Now Composer will try to pull down translations for WordPress, and your plugins and themes from every time you install or update a package.


This is one of the original drawbacks that I want to fix, which should be possible with the current structures: Translations are only downloaded when a package (i.e. WordPress, plugin or theme) is installed or updated. This means that if a translation package for a version you already have installed is updated, the translation won’t be updated until a new version of the plugin/theme is released.

Maybe you can help me fix it?

Published by

Bjørn Johansen

Bjørn has been a full-time web developer since 2001, and have during those years touched many areas including consulting, training, project management, client support, and DevOps. He has worked with WordPress for more than 13 years, and he is a plugin author, core contributor, WordCamp speaker, WordCamp co-organizer and Translation Editor for Norwegian Bokmål.


    1. Thanks, Peter.
      I’m using the same Composer events as you are using. Guess I’ll have to see how you solved it :-)

      1. I looks like you did a more thorough rewrite and therefore has nicer code overall. Your Composer integration also looks a much better, but I have more features. We should merge the projects. What do you say?

  1. امروزه با توجه به کیفیت پایین آب لوله‌کشی شهری و نیاز به جداسازی مواد مضرر و بیماری‌زا از آن، دستگاه‌های تصفیه آب به یکی از لوازم ثابت اکثر خانه‌ها تبدیل شده‌اند. از آنجا که آب یکی از ملزومات زنده بودن انسان‌ها است، دسترسی به آب سالم و گوارا نیز اهمیت بسیاری پیدا می‌کند. پزشکان و متخصصان توصیه می‌کنند که هر فرد برای داشتن بدن سالم روزانه حدود 8 لیوان آب بنوشد، بدیهی است که در صورتی که این آب املاح مفید کافی داشته و عاری از املاح مضرر باشد، می‌تواند به سلامت انسان کمک کند و در غیر این صورت حتی می‌تواند عامل ابتلا افراد به بیماری‌های مختلف نیز باشد. پس در این مطلب ابتدا به این موضوع می‌پردازیم که آب شهری چه مشکلاتی می‌تواند داشته باشد و ضرروت استفاده و خرید دستگاه تصفیه آب را بررسی می‌کنیم، سپس انواع دستگاه تصفیه آب را بر شمرده و به چگونگی تولید آب سالم و گوارا می‌پردازیم.

  2. چراغ جلو خودرو وظیفه روشنایی مسیر را بر عهده دارد. یکی از انواع لامپ¬هایی که در کنار لامپ هالوژنی و لامپ زنون در چراغ¬های خودرو مورداستفاده قرار می¬گیرد هدلایت است.

    هدلایت لامپ LED است که به‌جای لامپ اصلی در چراغ جلو ماشین قرار می¬گیرد.

    هدلایت¬ها طول عمر طولانی دارند و در برابر ضربه در تصادفات نسبت به لامپ معمولی ماشین مقاومت بالاتری از خود نشان می¬دهند قیمت لامپ هدلایت مصرف انرژی کمی دارند و سریع روشن می¬شوند.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.