Add or import languages in a Sitecore-first JSS Next.js app
When working Sitecore-first in a project created with the Sitecore Containers template for Next.js, you might need to deploy new languages or import previously deployed languages and items in that language.
Add a language to the Sitecore-first Next.js project
The Next.js JSS application created when you create your development project using the Sitecore Containers template for Next.js has examples for multilingual Styleguide components that have language routes. For the language routes to work, you must add the language for those routes to Sitecore.
To add a new language to the Sitecore instance in the Sitecore-first Next.js project:
-
Add the language to /sitecore/system/Languages. The Next.js sample app uses Danish (
da-DK). -
Deploy the items in that language:
RequestResponsejss deploy items --language=da-DK --includeContent --includeDictionary -
Publish the language:
RequestResponsedotnet sitecore publish
Import a deployed language to your serialized items
To import items for a previously deployed language into the serialized items of your containerized Sitecore-first project:
-
In the file
src/InitItems.module.jsonin your containerized project, add a serialization configuration for languages. For example:RequestResponse{ "name": "languages", "path": "/sitecore/system/Languages", "scope": "descendantsOnly", "rules": [ { "path": "/en", "scope": "ignored" } ] } -
In a terminal, in the root directory of the project, run the following command:
RequestResponsedotnet sitecore ser pull