Coder Social home page Coder Social logo

di18n-translate's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

di18n-translate's Issues

Project Licence

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!

issue

di18n-translate在ie中一直报对象不支持forEach,怎么都解决不了

最新版不支持 i18n-placeholder 属性?

<!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>

切换的时候有问题

小Bug

setLocale函数需要把currentMessage改为当前语言环境

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.