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 wordpress.org. 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 wordpress.org to download the translations for you. That is a great idea, and works with every plugin and theme hosted on wordpress.org!
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.json
file:
"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 wordpress.org every time you install or update a package.
Drawbacks
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?
Oh, that is interesting. I have made a similar refactor recently and I fixed most of the problems with that package, including the drawbacks you mention. My fork use “post-package-install” and “post-package-update” composer events.
Link: https://github.com/pelmered/composer-plugin-language-update
Thanks, Peter.
I’m using the same Composer events as you are using. Guess I’ll have to see how you solved it :-)
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?
Excellent. Actually your content is useful
hi very very nice
goodluck
Hi, Saeed is from Iran
The post was very good. Thank You
Is gutenberg the future for wordpress?
thanks
The post was very good. Thank You
if you looking fir best cosmetic services you can go to vanakclinic
https://www.vanakclinic.com
the best Pediatric surgeon in iran: Dr salahedin delshad
http://drdelshad.ir
I tried Composer wplang there are a few comments sent to you by mail.
tnx for sharing informaion
good job
Sadly, this plugin is not compatible with Composer 2
معمولا وارد شدن آسیب، وجود یک عامل تحریک یا تحت فشار قرار گرفتن یکی از عصبها یا رشتههای عصبی بازو، مچ دست و پا علت شایع مورمورشدن یا خواب رفتن دست و پا شناخته شده است.
one of things that is helpful for me i need to say
its thank you for your page
به دلایل مختلفی مانند مشکلات درون سرچ کنسول،بهبود سرعت و … شما ممکن است مایل به بستن خوراک وردپرس و یا همان rss feed سایت خود باشید. برای غیرفعال کردن خوراک وردپرس با ما همراه باشید.
به دلایل متفاوتی ممکنه که شما بخواهید هدر و فوتر سایت خود را در صفحه ای مخصوص و یا در تمام صفحات پنهان کنید بدون اینکه هدر و فوتر وبسایت را کاملا حذف کنید.
طراحی سایت بهترین شرکت طراحی سایت درایران
حذف موهای زائد بدن به وسیله لیزر به علت دائمی بودن آن، بی خطر، ایمن بودن و بیدرد بودنش بهترین و محبوبترین روش برای حذف موهای زائد بدن است. لیزر موهای زائد در قم با بهرهگیری از متخصصان این علم و زیر نظر پزشک، آماده ارائه خدمات به همشهریان عزیز قمی است.
لیزر موهای زائد
فیلم PVB تولید شده توسط شرکت رازین پلیمر دارای خواص مکانیکی، فیزیکی و اپتیک ویژه بوده و براساس استاندارد مورد تایید صنعت شیشه دنیا تولید و عرضه میشود. در آزمایشگاه شرکت رازین پلیمر راه ابریشم علاوه بر کنترل کیفی فیلم PVB، شیشهی ایمنی لمینیت شده با فیلم PVB بر اساس استاندارد ECER43 مورد آزمایش تستهای سقوط گلوله، مدل ضربه سر، آب جوش، واپیچش نور، سنجش جذب UV و … قرار میگیرد.
تمامی فیلمهای PVB تولید شده توسط شرکت رازین پلیمر راه ابریشم، همواره با یک لایه پلیاتیلن کلرینیت شده پیچیده شده و درون اتاقهای تمیز خطوط تولید این شرکت، با فیلمهای سه لایه الومینیومی وکیوم و عایق بندی میگردد.
طلاق توافقی مراحلی داره که باید قبل از شروع اون ها رو بدونیم
قسمت طراحی سایت در سپیداران وب بین 1 الی 2 میلیون تومان
طراحی سایت بهترین شرکت طراحی سایت درایران
تارینوتک، بهترین شرکت طراحی سایت در ایران!
در دپارتمانهای مختلف شرکت رازین پليمر راه ابریشم فارغ التحصيلان و متخصصان جوان و با تجربه از بهترین مراكز علمي و آموزشی كشور فعال بوده و با هدف توسعه روز افزون و ارتقای كيفيت محصولات ارائه شده تلاش میكنند.