Creating web contents for multiple languages

There might be a scenario to create web content in multiple languages available on portal. But we are aware of the structure but not able to create the content jus with the create request for web content. This can be solved by adding few parameters to the request body.

 

We need to add what are the available languages in the portal as 

"availableLanguages": ["language1","language2"]

and for each content field we need to provide the translations 

{
      "contentFieldValue": {
        "data": "<p>desc</p>"
      },
      "contentFieldValue_i18n": {
        "language1": {
        "data": "<p>desc</p>"
      },
        "language2": {
        "data": "<p>desc-arabic</p>"
      }
      },
      "name": "description"
    }

if we pass the jus with the contentFieldValue with out the translation it sets only the default values for the fields available in structure, if we pass the same request which is not having translations with Accept-Language header, it would place the content for the specific language mentioned in header but also removes the translation preset for other languages. It assumes that user want to replace the content for specific language. Below is a sample request to create the content for a custom structure.

 

{
    "availableLanguages": ["en-US","ar-SA"],
    "contentFields": [{
      "contentFieldValue": {
        "data": "<p>desc</p>"
      },
      "contentFieldValue_i18n": {
        "en-US": {
        "data": "<p>desc</p>"
      },
        "ar-SA": {
        "data": "<p>desc-arabic</p>"
      }
      },
      "name": "description"
    }],
     "contentStructureId": 54938,
     "structuredContentFolderId": 54270,
     "title":"test3",
     "title_i18n":{
        "en-US":"test3",
        "ar-SA":"test3-arabic"
     },
     "taxonomyCategoryIds": [54925,47490]
    }