jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.68k stars 309 forks source link

:sparkles: support for generic locale alexa manifest definition #1542

Closed sadlowskij closed 1 year ago

sadlowskij commented 1 year ago

Proposed Changes

I think it would be handy to support the generic locales defined in the AlexaCliConfig (AlexaCliConfig.locales) to be applied to the specific locales for the localized sections of the manifest publishingInformations and privacyAndCompliance.

My Commit would make it possible, to either define one of those properties for a specific locale (e. g. just for en-AU) while also being able to define one en generic locale, that gets applied to all other en locales that don't have a specific entry.

So with a config like this:

    new AlexaCli({
      locales: {
        en: ['en-AU', 'en-US', 'en-IN'],
        de: ['de-DE']
      },
      files: {
        'skill-package/skill.json': {
          manifest: {
            publishingInformation: {
              locales: {
                en: {
                  info: "All en have this"
                },
                de: {
                  info: "All de have this"
                }
              }
            },
            privacyAndCompliance: {
              locales: {
                'de': {
                  privacyPolicyUrl: 'https://test.com/de/datenschutz/',
                  termsOfUseUrl: 'https://test.com/de/agb/',
                },
                // Will be applied to en-US and en-IN
                'en': {
                  privacyPolicyUrl: 'https://test.com/en/privacy/',
                  termsOfUseUrl: 'https://test.com/en/tos/',
                },
                'en-AU': {
                  privacyPolicyUrl: 'https://test-au.com/en/privacy-australia/',
                  termsOfUseUrl: 'https://test-au.com/en/tos-australia/',
                },
              },
              allowsPurchases: false,
              containsAds: false,
              isChildDirected: false,
              isExportCompliant: true,
              usesPersonalInfo: false,
            },
          },
        },
      }
    })

So it will lead to:

{
  "manifest": {
    "publishingInformation": {
      "locales": {
        "de-DE": {
          "info": "All de have this"
        },
        "en-AU": {
          "info": "All en have this"
        },
        "en-US": {
          "info": "All en have this"
        },
        "en-IN": {
          "info": "All en have this"
        }
      }
    },
    "privacyAndCompliance": {
      "locales": {
        "en-AU": {
          "privacyPolicyUrl": "https://test-au.com/en/privacy-australia/",
          "termsOfUseUrl": "https://test-au.com/en/tos-australia/"
        },
        "de-DE": {
          "privacyPolicyUrl": "https://test.com/de/datenschutz/",
          "termsOfUseUrl": "https://test.com/de/agb/"
        },
        "en-US": {
          "privacyPolicyUrl": "https://test.com/en/privacy/",
          "termsOfUseUrl": "https://test.com/en/tos/"
        },
        "en-IN": {
          "privacyPolicyUrl": "https://test.com/en/privacy/",
          "termsOfUseUrl": "https://test.com/en/tos/"
        }
      },
      "allowsPurchases": false,
      "containsAds": false,
      "isChildDirected": false,
      "isExportCompliant": true,
      "usesPersonalInfo": false
    },
    "apis": {
      "custom": {
        "endpoint": {
          "sslCertificateType": "Wildcard",
          "uri": "[URL]"
        }
      }
    }
  }
}

It also makes sure to remove the generic locales from the properties, as this would break in the deployment

Types of Changes

Checklist

aswetlow commented 1 year ago

Very useful! Thank you