Using localization for client side

Posted: April 14, 2015 at 8:42 AM Quote #143466
Most of the code that's there on client side includes hard coded messages in English language. For localization purposes, they should be moved to a separate javascript object through a view and then that object should be used inside scripts.


That I believe is a nice way to avoid hardcoding any English literals in the script files.

For example in public.onepagecheckout.js on line 333 we see something like this

validate: function () {
        var methods = document.getElementsByName('paymentmethod');
        if (methods.length == 0) {
            alert('Your order cannot be completed at this time as there is no payment methods available for it.');
            return false;
        }


This can easily be replaced by

validate: function () {
        var methods = document.getElementsByName('paymentmethod');
        if (methods.length == 0) {
            alert(localized_data.NoPaymentMethodsError);
            return false;
        }


where localized_data is a javascript object parameter that'll be passed from the view itself.
This post/answer is useful
2
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
nopCommerce enthusiasts since 3.10
nopCommerce themes & plugins available @ https://www.roastedbytes.com
Posted: April 14, 2015 at 8:46 AM Quote #143467
Hi Anshul,

Thanks a lot for suggestion. I've just created a work item
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Andrei Mazulnitsyn
Posted: September 09, 2019 at 3:14 AM Quote #245976
Done. Please see this commit.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Dmitriy Kulagin
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.