Localize your Developer Portal
Your Developer Portal can be easily internationalized, either by Mashery or with client-provided translations.
- All hard-coded strings should be passed through the
translate()method. Pass in the ID for the current view, and a unique ID (within the view) for the string itself.
// templates.js
portal.setDefault('mypage', function (data) {
return `
<h1>${portal.translate('mypage', 'title')}</h1>
<p>${portal.translate('mypage', 'greeting')}</p>`;
});
- Pass an object of default values into the
addTranslations()method for that view.
portal.addTranslations('default', {
'mypage': {
title: 'Hello, world!',
greeting: 'How are you today?'
}
});