Samagra-Development / templater

Template Manager
2 stars 8 forks source link

Added: i18n APIs #7

Closed radhay-samagra closed 2 years ago

radhay-samagra commented 2 years ago

Create Request Body

POST /i18n

{
    "meta": {},
    "bodyI18n": {
        "createMany": {
            "data": [
                {
                    "lang": "en",
                    "body": "Hello World. This is ${name}. I love (to) ${task}"
                },
                {
                    "lang": "hindi",
                    "body": "Hello World. This is ${name}. I love (to) ${task}"
                }
            ]
        }
    },
    "type": "JS_TEMPLATE_LITERALS",
    "user": "25bbdbf7-5286-4b85-a03c-c53d1d990a23"
}

Render Request Body

POST /i18n/process

{
    "id": 5,
    "data": {
        "lang": "en",
        "name": "Chakshu",
        "task": "shave yaks"
    }
}

Render Response Body

If lang provided, then only the provided lang will be rendered

{
    "processed": "Hello World. This is Chakshu. I love (to) shave yaks",
    "templateType": "JS_TEMPLATE_LITERALS",
    "data": {
        "lang": "en",
        "name": "Chakshu",
        "task": "shave yaks"
    },
    "template": "test",
    "meta": {}
}

If lang not provided in body

{
    "processed": [
        {
            "lang": "en",
            "processed": "Hello World. This is Chakshu. I love (to) shave yaks"
        },
        {
            "lang": "hindi",
            "processed": "Hello World. This is Chakshu. I love (to) shave yaks"
        }
    ],
    "templateType": "JS_TEMPLATE_LITERALS",
    "data": {
        "name": "Chakshu",
        "task": "shave yaks"
    },
    "template": "test",
    "meta": {}
}
ChakshuGautam commented 2 years ago

@radhay-samagra please update the spec to include ISO language codes.

radhay-samagra commented 2 years ago

@ChakshuGautam Added the ISO Language Codes for lang property