There is no easy solution for that. What I would probably do is create several scripts with language texts for every language and include proper one in PHP. So if someone is using english version of your site you would include only english file, if someone is using german version you would include german language file etc.
Example:
// your script logic
myscript.js
// language texts
myscript.en.js
myscript.de.js
myscript.it.js
...
You can define all language files like that:
LANG = {
txt1: 'English text1',
txt2: 'English text2'
...
};
Make sure you are including only one of those in your HTML and make sure to include language file first i.e.
<script type="text/javascript" src="myscript.de.js"></script>
<script type="text/javascript" src="myscript.js"></script>
Then you can use those localized texts in your main script for example:
$(document).ready(function () {
alert(LANG.txt1);
});
What's best about it is that your logic (myscript.js
in this example) doesn't have to worry about localization and you won't have to change it if you want to add a new language file.