Reputation: 119
I tried to localize my web app with jquery.i18n but I have some problems with umlauts.
In my jsp page I set the following:
<meta charset="utf-8">
<script type="text/javascript"
src="script.js"
charset="utf-8"></script>
<label data-i18n="specification"> Specification / Ausprägung </label>
script.js
$(document).ready(
function() {
//onload
$.i18n().load({
'de' : '/js/i18n/de.json'
}).done(
function() {
$.i18n().locale = 'de';
$('body').i18n();
});});
And the de.json:
{
"@metadata": {
"authors": [
"xyz"
],
"last-updated": "2018-06-06",
"locale": "de"
},
"specification" : "Ausprägung"
}
but all I get is Auspr�gung
. Beside the umlauts, jquery.i18n works fine. How can I make it use utf-8 encoding?
Upvotes: 1
Views: 1384
Reputation: 146660
UTF-8 should be the default for any library nowadays and jquery.i18n, while not bleeding edge, appears to be a serioius project. Being precise, the JavaScript interpreter will automatically parse source code encoded as UTF-8 and convert strings to its internal encoding. I bet the library works with any encoding out of the box as long as it's properly declared (e.g. by sending a correct Content-Type
header).
The �
character in Auspr�gung
is a typical symptom of single-byte encoding misinterpreted as UTF-8. Your editor is probably configured to save files as ANSI (Windows-1252 or whatever) but the stack is configured to assume UTF-8.
Upvotes: 1