blade1989 / NewOS

Seeking for a new os? you've come to the right place!
http://blade1989.github.io/NewOS/
0 stars 0 forks source link

Bilingual website using i18next #32

Open blade1989 opened 9 years ago

blade1989 commented 9 years ago

i18next is:

i18next is a full-featured i18n javascript library for translating your webapplication.

usage sample:

--------------------HTML--------------------

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="[PATH]/jquery.js" /> // optional
    <script type="text/javascript" src="[PATH]/i18next.js" />
  </head>
  <body>
    <ul class="nav">
      <li><a href="#" data-i18n="nav.home"></a></li>
      <li><a href="#" data-i18n="nav.page1"></a></li>
      <li><a href="#" data-i18n="nav.page2"></a></li>
    </ul>
  </body>
</html>

--------------------JSON--------------------

  {
    "app": {
      "name": "i18next"
    },
    "nav": {
      "home": "Home",
      "page1": "Page One",
      "page2": "Page Two"
    }
  }

--------------------JS--------------------

  i18n.init(function(t) {
    // translate nav
    $(".nav").i18n();

    // programatical access
    var appName = t("app.name");
  });

If not js I could also use the equivalent to php: