airbnb / polyglot.js

Give your JavaScript the ability to speak many languages.
http://airbnb.github.io/polyglot.js
BSD 2-Clause "Simplified" License
3.71k stars 208 forks source link

Support nested phrase objects #12

Closed spikebrehm closed 10 years ago

spikebrehm commented 10 years ago
polyglot.extend({
  "nav": {
    "hello": "Hello",
    "hello_name": "Hello, %{name}",
    "sidebar": {
      "welcome": "Welcome, %{name}"
    }
  }
});

polyglot.t("nav.sidebar.welcome", {name: "Raph"});
=> "Welcome, Raph"

Closes ,https://github.com/airbnb/polyglot.js/issues/10, https://github.com/airbnb/polyglot.js/pull/11, and maybe https://github.com/airbnb/polyglot.js/pull/8.