diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index b741955cda35a5dc71db6e24e8c069814ec1d3bd..da7f146cfcedf5ea621b478b4a0d9338ecd12ea0 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -85,19 +85,13 @@ function lessFacets(id) { } // Phone number validation -var libphoneTranslateCodes = ["libphonenumber_invalid", "libphonenumber_invalidcountry", "libphonenumber_invalidregion", "libphonenumber_notanumber", "libphonenumber_toolong", "libphonenumber_tooshort", "libphonenumber_tooshortidd"]; -var libphoneErrorStrings = ["Phone number invalid", "Invalid country calling code", "Invalid region code", "The string supplied did not seem to be a phone number", "The string supplied is too long to be a phone number", "The string supplied is too short to be a phone number", "Phone number too short after IDD"]; function phoneNumberFormHandler(numID, regionCode) { var phoneInput = document.getElementById(numID); var number = phoneInput.value; var valid = isPhoneNumberValid(number, regionCode); if(valid != true) { if(typeof valid === 'string') { - for(var i=libphoneErrorStrings.length;i--;) { - if(valid.match(libphoneErrorStrings[i])) { - valid = vufindString[libphoneTranslateCodes[i]]; - } - } + valid = vufindString[valid]; } else { valid = vufindString['libphonenumber_invalid']; } diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml index e9cb2e0784fd03d00b16646d92852e500449a13a..03f2d14dfdca23886d5e34b82cb957b1b3b5c9f7 100644 --- a/themes/bootstrap3/templates/layout/layout.phtml +++ b/themes/bootstrap3/templates/layout/layout.phtml @@ -30,6 +30,7 @@ // Deal with cart stuff: if (!isset($this->renderingError)) { + // Add translation strings $this->jsTranslations()->addStrings( array( 'add_tag_success' => 'add_tag_success', @@ -49,6 +50,18 @@ 'number_thousands_separator' => ['number_thousands_separator', null, ','] ) ); + // Add libphonenumber.js strings + $this->jsTranslations()->addStrings( + array( + "'Phone number invalid'" => 'libphonenumber_invalid', + "'Invalid country calling code'" => 'libphonenumber_invalidcountry', + "'Invalid region code'" => 'libphonenumber_invalidregion', + "'The string supplied did not seem to be a phone number'" => 'libphonenumber_notanumber', + "'The string supplied is too long to be a phone number'" => 'libphonenumber_toolong', + "'The string supplied is too short to be a phone number'" => 'libphonenumber_tooshort', + "'Phone number too short after IDD'" => 'libphonenumber_tooshortidd' + ) + ); $cart = $this->cart(); if ($cart->isActive()) { $this->headScript()->appendFile("vendor/cookies.js");