Add or import languages in a JSS Next.js app
When working in a JSS Next.js project, you might need to deploy new languages or import previously deployed languages and items in that language.
Add a language to the Next.js project
The Next.js JSS application created when you create your development project 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 CM instance in the 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 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