Skip to content
example using formatjs with locize
HTML CSS JavaScript
Branch: master
Clone or download
Latest commit 0f4ab66 Jul 22, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore initial version Jul 22, 2016
README.md initial version Jul 22, 2016
index.html initial version Jul 22, 2016
index.js initial version Jul 22, 2016
package.json initial version Jul 22, 2016
style.css

README.md

locize-formatjs-example

Example how to use FormatJS and locize.com using a node.js server.

Same rules apply to react-intl,...

starting the sample

npm i
npm start

open localhost:8080 in your browser

What we do:

  1. We use the locize API Fetch Route to load the translations
  2. We add the translation resources and language to js vars in the returned html
  3. From there we use yahoo/intl-messageformat like
function t(key, opts) {
  opts = opts || {};
  var m = new IntlMessageFormat(resources[key], lng);
  return m.format(opts);
}

Alternatively you could also load the resources via xhr and translate onLoaded

You can’t perform that action at this time.