How to localize Javascript shopping cart

VirtoCommerce have a module that allows adding a basic shopping cart and checkout functionality to the website easily: https://github.com/VirtoCommerce/vc-module-javascript-shoppingcart.
Integration sample could be found here:
https://github.com/VirtoCommerce/vc-samples/tree/master/JsShoppngCartIntergationSample

Below I will guide you on how to localize the module content, e.g. Checkout form. Here is how it looks by default:


To add another language support, e.g. Russian, you need to do the following:

  1. Find and copy translations.js file, name copy ru.translations.js
    image
  2. Change defined constant name to e.g. 'virtoCommerce.cartModule.ruTranslations', and use any translations you want:
  3. Add created localization object to the translations collection in cart.js:
  4. To use Russian translations by default, you could change preferred language to 'ru' in config section above:
    $translateProvider.preferredLanguage('ru');
  5. To switch between languages in runtime, you can call in your language switching handler:
    $translate.use('ru');

After building and installing the module and restarting the platform, checkout form looks like this:

1 Like