2

I'm building an online store using Magento version 2.1.8. I've created a Luma child-theme.

Magento offers CSV files for translating most of it. But the minicart uses JavaScript for the text strings within it.

enter image description here

How can I overwrite the default English text, for Romanian?

3
  • If i recall correctly this should be also included in the CSV you mentioned, no matter if it is PHP or JS.
    – mbalparda
    Commented Sep 19, 2017 at 14:52
  • The Magento installation has many CSVs (every module has one). Wich CSV are you writing about? Commented Sep 19, 2017 at 15:01
  • I don't know which text are you trying to translate, but you can try something like this to search in the CSV files github.com/magento/magento2/…
    – mbalparda
    Commented Sep 19, 2017 at 15:46

2 Answers 2

3

For JS translate you must create language pack with below files.

/app/i18n/Myshop/ro_ro/language.xml:

<?xml version="1.0"?>
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd">
    <code>ro_RO</code>
    <vendor>Myshop</vendor>
    <package>ro_ro</package>
</language>

/app/i18n/Myshop/ro_ro/registration.php:

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
    'myshop_ro_ro',
    __DIR__
);

/app/i18n/Myshop/ro_ro/ro_RO.csv with your translates (examples):

"Cart Subtotal:","Costul mărfurilor:"
"Go to Checkout","Du-te la checkout"
...

For apply your store must use Romanian locale, of course. JS translates are stored in /pub/static/frontend/Myshop/Mytheme/ro_RO/js-translation.json.

Remove this file for refresh, clear cache and browser local storage. Enjoy!

27
  • The file/directory structure is different from yours, in Magento 2 Commented Sep 20, 2017 at 7:33
  • The Vendor directory is directly under root. Commented Sep 20, 2017 at 7:40
  • Vendor in paths in my answer is your vendor, replace it to your development's name. It's not vendor directory under root. Commented Sep 20, 2017 at 13:09
  • What is the right path in Magento version 2.1.8? Commented Sep 20, 2017 at 14:43
  • 1
    i18n inside theme not work for JS translates. It's works in PHP only. Commented Sep 21, 2017 at 11:58
0

Hello Evgeny Levinsky I have similar issue with italian language. But I'm not understanding where exactly I should create the files which you explained in the above answer. My theme files are stored in following location app/design/frontend/TemplateMonster/theme055 inside that one i18n directory is there but inside that only csv files are there. Should i create inside that or should I create new directory as following app/i18n/TemplateMonster/theme055

Please help about this. this is little urgent.

Thank You, Kishan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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