1

I want to translate KO text.

"You have no items in your shopping cart." "Empty Basket" 

Already tried with translate.csv it doesn't work.

Is there any way to translating knockout template text in magento2?

6
  • your text is in html template or js file ? Commented Jun 12, 2018 at 11:26
  • knockout html file. Commented Jun 12, 2018 at 11:28
  • can you put your sample code ? Commented Jun 12, 2018 at 11:30
  • @SanjuAntala can you try : magento.stackexchange.com/questions/121251/… Commented Jun 12, 2018 at 11:30
  • May be you need to flush cache and static content deploy. Commented Jun 12, 2018 at 11:34

2 Answers 2

0

You Can try this its work for me.

find pub/static -name js-translation.json 

Add your translation in theme js-translation.json

For Example:

{"You have no items in your shopping cart.":"Empty Basket"} {"Forgot Your Password?":"Forgot Password?"} 

Once that's done we clear the cache:

php bin/magento cache:clean php bin/magento cache:flush 
3
  • 1
    It's working thanks, man! Can you explain where can locate that file in my theme? Commented Jun 12, 2018 at 11:39
  • 1
    @SanjuAntala its auto-generated file, no need to copy that. Just add your text in translate.csv than clean your cache Commented Jun 12, 2018 at 11:45
  • 1
    Thanx @Chetan its work for me. Commented Jun 12, 2018 at 11:48
0

Try following code

<!-- ko i18n: 'You have no items in your shopping cart." "Empty Basket' --><!-- /ko --> 

Translate it into i18n directory of your module. & last thing is make deploy.

 rm -rf pub/static/frontend php -dmemory_limit=1G bin/magento setup:static-content:deploy -f chmod 777 -R var/ pub/static generated/ 
2
  • Wt happen when multiple texts translate? check @chetan above answer its works for me and it's easy to solution. Commented Jun 12, 2018 at 12:08
  • Thanx, dude! For Replay... Commented Jun 12, 2018 at 12:17

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.