Localiztion in javascript

WordPress has a nice function mainly for that wp_localize_script

To use it first queue your script:

wp_enqueue_script( 'My_Script_handle', 'path/to/script.js' );

then create an array of strings you want to localize:

$data = array( 
   'exit' => __( 'Exit','my-plugin-domain' ),
   'open' => __( 'Open','my-plugin-domain' ),
   'close' => __( 'Close','my-plugin-domain' ),
   'next' => __( 'Next','my-plugin-domain' ),
   'previous' => __( 'Previous','my-plugin-domain' )
);

and call it using wp_localize_script

wp_localize_script( 'My_Script_handle', 'mystrings', $data );

then you can access it in the page using JavaScript like this:

alert(mystrings.exit);
alert(mystrings.open);

you get the Idea.