Translating Magento 2 - Installing custom language pack(s)

Hi Craig,

Thank you for your prompt reply.
I’ve done it :slight_smile: The translation is applied to the mini cart too.

I found this article: https://magento.stackexchange.com/questions/193830/magento-2-how-to-translate-the-minicart?rq=1

I removed the file /pub/static/frontend/Magento/luma_child/en_GB/js-translation.json cleared caches like Evgeny Levinsky adviced and it worked.

We learn things every day haaa :slight_smile:!

I hope that it will be be useful for someone.

Regards,
Pawel

1 Like

Hi Craig,

I’m again straggling to install a language pack.
This time I tried to do it via composer but the following error message was shown.

Can you please advise how to bite it?
Thank you.

Pawel

Luckily, this is an easy one and nothing you’ve done wrong per se. A quick analysis of the situation should explain…

The “latest” version of the Packagist Composer Repository is out-of-date (2017-09-28). Therefore, not compatible with Magento 2.2, 2.3. Hence the error message you’re seeing.

If you look at the dev-master version of the Packagist Repository, you will see that this branch was updated very recently (2019-08-07). It’s safe to assume that this update addresses the issue.

So, instead of specifying the “latest” version, you should specify the “dev-master” version when loading composer:

composer require cubewebsites/magento2-language-en-gb:dev-master

If you checkout the GitHub Repository, the only difference between the 2 versions is a line in the composer.json that tells composer its requirements (i.e. the compatibility with Magento 2.2, 2.3).

Hi Craig,
Thank you for the tip. It worked, I was able to install the module but I’m still looking at creating my own langage packadges.
In the past I was able to do it for M.2.2 but for some reasons I can’t do it for M2.3.2

The procedure of creating langage packs for both M2.2 and M2.3 looks very similar.
source - https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-i18n.html
So I created the following directories and files:

app/i18/mystore/en_GB for British English and analogically 
app/i18/mystore/fr_FR for French - France 
app/i18/mystore/de_DE for German - Germany

- composer.json
- registration.php
- langage.xml
- en_GB.csv
- fr_FR.csv
- de_DE.csv

Uploaded relevant files into relevant directory.

composer.json, registration.php, langage.xml, en_GB.csv to app/i18/mystore/en_GB

Finally, run the following commands:

bin/magento setup:static-content:deploy en_GB -f
bin/magento setup:upgrade
bin/magento cache:flush

But it doesn’t work.

My composer file looks as follow:

My language.xml file looks as follow:

My registration.php file looks as follow:

I would like to confirm that I’ve checked my Magento admin conf. and my locale settings are correct.
I don’t know what I’m doing wrong. It should be so simple. Probably I’m not running a correct command or missing one.
I check Magento documentation and checked so many different forums. When you have time can you please look at it?

If anyone knows what I’m doing wrong please let me know.
If anyone would like to have a go the below screenshot might be useful.

Thank you.
Pawel

I haven’t had a chance to thoroughly read through your post because I’m signing off for the day, but I’ll have a look tomorrow.

However, I just wanted to point out that you referenced the below command:

bin/magento setup:static-content:deploy en_GB -f

But you didn’t include the 2 other languages:

bin/magento setup:static-content:deploy en_GB fr_FR de_DE -f

As I said, I’ll check back in tomorrow.

Hi Craig,

You are absolutely correct. I wasn’t clear in my message. I’m only testing en_GB. If I can make one language works I’m sure the remaining 2 will work too.

It is really annoying because I already went through this once and it worked.
I have a feeling that I’m going backwards.

Please take your time. There is no rush. I’m sitting on this for last 2 weeks.
I tired on a few magento instances, including vanish but it just don’t work.

Thank you for your time.

Pawel

After about an hour, I’ve come to the conclusion that the Official Documentation sucks. When I have more time to get my head around it, I’ll get back to you (and probably produce a video).

I’m such an idiot. No wonder what I was doing wasn’t working! I forgot I installed the CubeWebsites GB Language Pack from the other night - And it was interfering with my own pack. I think I have it working now.

Hi Craig,
As I said take your time.
I tired for maybe 2 to 3 weeks to make this working before I asked you for help. I’m not a programmer but it shouldn’t be so difficult following M docs.

A video would be great. Of cource if you have time. You could break it into steps, creating storeviews, changing locale settngs in the admin pannel, changing or adding currencies, creating language packs and finally, I havent reserched this yet, how to conf. a site for mulpiple domains i.e mystore.co.uk, mystore.fr, mystore.ge and mystore.com/en, mystroe.com/de, mystore.com/fr.

Also, I know that it could be tricky, how to install SSL from multidoman website. I already cracked how to do it for single domain from godaddy, (I can write something here hopefuly it will be useful). I also tried installing SSL following your “let’s encript” toutorial. I think that this will be a biggy one but at first I need to lern how to creatre language packs.

Pawel

Have you installed a langauge pack via composer or have you created one?

My main goal was to work out and understand the Documentation. Specifically, I wanted to understand what the following 3 commands did:

  • bin/magento i18n:collect-phrases ...
  • bin/magento i18n:pack ...
  • bin/magento i18n:uninstall ...

collect-phrases and unistall were pretty straight forward. But it was pack that had me confused because I couldn’t work out for the life of me what it was actually doing.

What it does is separate and distribute your translation file into all of the appropriate (referenced) modules within their respective “i18n” folders. Very clever.

What didn’t help was that Test Translations I was expecting to see, didn’t display. And as I mentioned above, that was thanks to the other language pack I installed previously - Which was overriding my changes.

So, at this point I’m pretty sure I understand the purpose and functions of the i18n commands.

To answer your question, I just wanted to Generate and Create my own and then try to deploy it. It shouldn’t take too long to work out how to package the pack. But there are a few ways this can be achieved such as; Module, Theme, Pack.

I’ll come back to you on that one when I have another slot of free time to investigate.

Thank you.

In therory this should be easy.

…and run a few commands.

Ironically, I have done it for the previous M v. updated it to the newest version and the translation works for all 3 languages. :angry:

I’ve uploaded my i18n Language Pack Sample Solution to GitHub. This has been tested and works on my setup.

If this doesn’t work for you, then there is a high chance that you have another language pack interfering.

Note: Unlike a standard module, this doesn’t require any bin/magento installation commands to get going.

Edit: I’m supposed to be “off” today, so I’ll check back in on Monday.

Hi Craig,

Thank you for your reply.
I tried your language packs but it still doesn’t work for me.
(Just to confirm I changed in your en_GB.csv file some phrases - “Zip/Postal Code”, “Postcode”)
Your language packs installation procedure don’t differ from what I was doing which is good but at the same time not good because I didn’t make it work.

The language.csv file differs slightly. I included only original and translated phrases in quotation marks
Zip/Postal Code", "Postcode"
your file contain both phrases, and what they relate to i.e. module and releaser i.e. “Zip/Postal Code”,“Zip/Postal Code”,module,Ess_M2ePro
(Just to confirm I tried both only en_US and en_GB phrases & en_US, en_GB, + module and releaser)

I’m installing a new Magento locally now to check it again.
I have a question. Once the language packages are installed they should work for all themes, shouldn’t they?

Do I have to register my vendor before I register my language pack with the vendor in your example digitalstartup? (Just to confirm I changed the vendor name to mine in the language pack files and in the directory)

If you could give me some tips it would be great. I don’ t know what to look for.
Thank you in advance.

Pawel

Yes, I believe so. One thing that I don’t know is this: You’re can add i18n translations to Modules, Themes and Language Packs. But I don’t know which takes Priority.

Just swap out any references for your own, whilst not forgetting to update the actual directory names (as you said). However, I didn’t actually need to do anything after uploading the files other than this:

bin/magento setup:static-content:deploy en_GB fr_FR -f
bin/magento cache:clean
bin/magento cache:flush

Then when I switched the Locale in the backend, I just cleared the Cache again. It was surprising simple.

If you’re going to be testing on a clean install later then stick with my original first - Because we know that definitely works.

Hi,

OK, I need to try on the a fresh Magento then because it looks like I did everyhting correctly but it doesn’t work on my current M installation.

My magento has been installed with default english UK language so I didn’t change anything in the locale in the backend. Only for the french language but this also dosnt work. It absulatuly driving me mad. It should be so simple to do it.

Hi Craig,

Finally, I made it work. It was me being stupid creating the directory. Instead of i18n i named it 18.
I was doing it over and over again.

I waisted 3 weeks :rage: and I wasted your time too.
I’m sorry.

By the way in your command the is an error. No colon need after bin/magento

Pawel

I feel your pain, as I’ve been there a few times :slight_smile:

I’ve fixed those commands now, thanks.

A post was split to a new topic: Developing with PhpStorm

A post was split to a new topic: Assigning each Store View a Unique Domain