commanderxl / di18n-translate Goto Github PK
View Code? Open in Web Editor NEWdi18n-translate
di18n-translate
Hello, I'd like to use "di18n.min.js" as a translation module in my project. Could you please tell me which kind of software license (GPL, MIT, Apache, etc.) is applied?
By the way, I would appreciate if you could release it under GPL license, thanks!
di18n-translate在ie中一直报对象不支持forEach,怎么都解决不了
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.i18n {
text-align: center;
font-size: 18px;
font-weight: 600;
}
.img-wrapper {
padding-top: 30px;
text-align: center;
}
</style>
</head>
<body>
<div class="img-wrapper">
<img src="" i18n-img="./imgs/${locale}/${locale}.png" width="50" height="50">
</div>
<p i18n-class="i18n" i18n-content="我就要用中文"></p>
<div i18n-content="你好"></div>
<!-- <input type="text" name="" i18n-placeholder="你好"> -->
<input type="text" i18n-placeholder="确定">
<!-- <input type="text" name="" i18n-placeholder="$t('aa',{val:bb})"> -->
</body>
<script src="./js/i18ns/di18n.min.js"></script>
<script src="./js/i18ns/en.js"></script>
<script src="./js/i18ns/zh.js"></script>
<script>
var i18n = {
locale: 'zh',
isReplace: true,
messages: {
en: i18n_en,
zh: i18n_zh
}
}
var di18n = new DI18n(i18n)
setTimeout(function(){
// i18n.locale = 'en'
// di18n = new DI18n(i18n)
di18n.setLocale('en', function () {
// 回调函数
console.log('切换语言完成')
let html = '<div class="title">$t("你好")</div><p class="desc">$t("我就要用中文")</p><div class="pwd-btn btn-hook">$t("确定")</div>'
console.log(di18n.$html(html))
// 变量$t 仅仅在 js中才可以渲染
var t = di18n.$t('我很好', {val: 'Really?'})
console.log(t,'t')
})
},1000)
</script>
</html>
切换的时候有问题
setLocale函数需要把currentMessage改为当前语言环境
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.