Skip to content

Instantly share code, notes, and snippets.

@jtyjty99999
Created February 19, 2014 07:28
Show Gist options
  • Save jtyjty99999/9087540 to your computer and use it in GitHub Desktop.
Save jtyjty99999/9087540 to your computer and use it in GitHub Desktop.
切换多语言
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
[data-i18n="hello"]:before {
content: "Hello Maksim!";
}
[data-i18n="hello"]:lang(ru):before {
content: "Привет Максим!";
}
</style>
</head>
<body>
<input type="button" value="切换到俄语" id="change">
<div data-i18n='hello'></div>
<script>
var b = document.getElementById('change');
change.onclick = function(){/*
var a = document.createElement('meta');
a.name='language';
a.content='ru';
console.log(a)
document.head.appendChild(a);
*/
document.querySelectorAll('[data-i18n]')[0].setAttribute('lang','ru')
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment