00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class Mage_Core_Helper_Js extends Mage_Core_Helper_Abstract
00033 {
00034
00035
00036
00037
00038
00039 protected $_translateData = null;
00040
00041
00042
00043
00044
00045
00046 public function getTranslateJson()
00047 {
00048 return Zend_Json::encode($this->_getTranslateData());
00049 }
00050
00051
00052
00053
00054
00055
00056 public function getTranslatorScript()
00057 {
00058 $script = 'var Translator = new Translate('.$this->getTranslateJson().');';
00059 return $this->getScript($script);
00060 }
00061
00062
00063
00064
00065
00066
00067
00068 public function getScript($script)
00069 {
00070 return '<script type="text/javascript">'.$script.'</script>';
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 public function includeScript($file)
00080 {
00081 return '<script type="text/javascript" src="'.$this->getJsUrl($file).'"></script>'."\n";
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 public function includeSkinScript($file)
00091 {
00092 return '<script type="text/javascript" src="'.$this->getJsSkinUrl($file).'"></script>';
00093 }
00094
00095
00096
00097
00098
00099
00100
00101 public function getJsUrl($file)
00102 {
00103 return Mage::getBaseUrl('js').$file;
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 public function getJsSkinUrl($file)
00113 {
00114 return Mage::getDesign()->getSkinUrl($file, array());
00115 }
00116
00117
00118
00119
00120
00121
00122 protected function _getTranslateData()
00123 {
00124 if ($this->_translateData ===null) {
00125 $this->_translateData = array(
00126 'Please select an option.' => $this->__('Please select an option.'),
00127 'This is a required field.' => $this->__('This is a required field.'),
00128 'Please enter a valid number in this field.' => $this->__('Please enter a valid number in this field.'),
00129 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.' =>
00130 $this->__('Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.'),
00131 'Please use letters only (a-z) in this field.' => $this->__('Please use letters only (a-z) in this field.'),
00132 'Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' =>
00133 $this->__('Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'),
00134 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.' =>
00135 $this->__('Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.'),
00136 'Please use only letters (a-z) or numbers (0-9) or spaces and # only in this field.' =>
00137 $this->__('Please use only letters (a-z) or numbers (0-9) or spaces and # only in this field.'),
00138 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.' =>
00139 $this->__('Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.'),
00140 'Please enter a valid date.' => $this->__('Please enter a valid date.'),
00141 'Please enter a valid email address. For example johndoe@domain.com.' =>
00142 $this->__('Please enter a valid email address. For example johndoe@domain.com.'),
00143 'Please enter 6 or more characters.' => $this->__('Please enter 6 or more characters.'),
00144 'Please make sure your passwords match.' => $this->__('Please make sure your passwords match.'),
00145 'Please enter a valid URL. http:// is required' => $this->__('Please enter a valid URL. http:// is required'),
00146 'Please enter a valid URL. For example http://www.example.com or www.example.com' =>
00147 $this->__('Please enter a valid URL. For example http://www.example.com or www.example.com'),
00148 'Please enter a valid social security number. For example 123-45-6789.' =>
00149 $this->__('Please enter a valid social security number. For example 123-45-6789.'),
00150 'Please enter a valid zip code. For example 90602 or 90602-1234.' =>
00151 $this->__('Please enter a valid zip code. For example 90602 or 90602-1234.'),
00152 'Please enter a valid zip code.' => $this->__('Please enter a valid zip code.'),
00153 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.' =>
00154 $this->__('Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.'),
00155 'Please enter a valid $ amount. For example $100.00.' =>
00156 $this->__('Please enter a valid $ amount. For example $100.00.'),
00157 'Please select one of the above options.' => $this->__('Please select one of the above options.'),
00158 'Please select one of the options.' => $this->__('Please select one of the options.'),
00159 'Please enter a valid number in this field.' => $this->__('Please enter a valid number in this field.'),
00160 'Please select State/Province.' => $this->__('Please select State/Province.'),
00161 'Please enter valid password.' => $this->__('Please enter valid password.'),
00162 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.' =>
00163 $this->__('Please enter 6 or more characters. Leading or trailing spaces will be ignored.'),
00164 'Please use letters only (a-z or A-Z) in this field.' => $this->__('Please use letters only (a-z or A-Z) in this field.'),
00165 'Please enter a number greater than 0 in this field.' =>
00166 $this->__('Please enter a number greater than 0 in this field.'),
00167 'Please enter a valid credit card number.' => $this->__('Please enter a valid credit card number.'),
00168 'Please wait, loading...' => $this->__('Please wait, loading...'),
00169 'Please choose to register or to checkout as a guest' => $this->__('Please choose to register or to checkout as a guest'),
00170 'Error: Passwords do not match' => $this->__('Error: Passwords do not match'),
00171 'Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.' =>
00172 $this->__('Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.'),
00173 'Please specify shipping method.' => $this->__('Please specify shipping method.'),
00174 'Your order can not be completed at this time as there is no payment methods available for it.' =>
00175 $this->__('Your order can not be completed at this time as there is no payment methods available for it.'),
00176 'Please specify payment method.' => $this->__('Please specify payment method.'),
00177
00178
00179
00180 'Your session has been expired, you will be relogged in now.' => $this->__('Your session has been expired, you will be relogged in now.'),
00181 'Incorrect credit card expiration date' => $this->__('Incorrect credit card expiration date'),
00182 );
00183 foreach ($this->_translateData as $key=>$value) {
00184 if ($key == $value) {
00185 unset($this->_translateData[$key]);
00186 }
00187 }
00188 }
00189 return $this->_translateData;
00190 }
00191
00192 }