View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

Translating Dynamic Content

If your backend is storing interlingual data (e.g. product data is entered in multiple languages via a CMS), you shouldn't rely on simple JSON locale files unless you're somehow planning on editing your locale translations dynamically. One option is to edit the locale translations programatically, either with a custom implementation or through a translation service. Sails/node-i18n JSON stringfiles are compatible with the format used by webtranslateit.com.

On the other hand you might opt to store these types of dynamic translated strings in a database. If so, just make sure and build your data model accordingly so you can store and retrieve the relevant dynamic data by locale id (e.g. "en", "es", "de", etc) That way, you can leverage the req.getLocale() method to help you figure out which translated content to use in any given response, and keep consistent with the conventions used elsewhere in your app.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.