Supporting multilingual applications in JSS
Sitecore JSS allows you to take advantage of the content language versioning feature of Sitecore.
There are typically two concerns with rendering translated data from Sitecore:
-
The primary page content.
-
Dictionary items used for translation of labels, button text, and so on.
The sample apps show one approach to using the tools provided by JSS to make your app fully translatable.
Rendering translated Sitecore content
When getting content from Sitecore, whether with GraphQL or with REST, the request is made behind the scenes to the Sitecore Layout Service.
The Layout Service respects the Sitecore Language Context when fetching route and context data, meaning that requests to the Layout Service can utilize the sc_lang
parameter to request content in a specific language. For example, http://JssReactWeb/sitecore/api/layout/render/jss?item=/Services&sc_lang=es-MX&sc_apikey={YOUR_API_KEY}
.
You can choose how you invoke the Layout Service and handle language changes.
If you set up your JSS project using one of the sample applications, your application already handles the fetching of layout data.
Acquiring Sitecore dictionary phrases
Sitecore JSS provides a Dictionary API to help you acquire translated phrases in a JSS app.
If you set up your JSS project using one of the sample applications, your application already handles the fetching of dictionary phrases.