Skip to content

Instantly share code, notes, and snippets.

@baflo
Last active April 26, 2019 08:25
Show Gist options
  • Save baflo/b88e636948b6b57c3f07af2672088961 to your computer and use it in GitHub Desktop.
Save baflo/b88e636948b6b57c3f07af2672088961 to your computer and use it in GitHub Desktop.
Example locales configuration as of Dialogbits Framework 0.5.0

Loads all TypeScript, JavaScript and JSON files from locales directory, if i18next backend is not configured. .ts files shadow .js files, .js files shadow .json files. The folder/file structure is resembled in the final locales object, while the filenames are camelcased, i.e. a folder main-state will be a key mainState, which will contain all content from that folder. If LocalesLoader finds an ES6 default export or an export the same name as the camelcased file name, only this is taken from the file. In any other case, everything is exported. Files and folders of the same name are merged. An example can be found here.

config│
└───locales
    └───en
        │   entities.ts
        │
        ├───translation
        │   │   help-state.ts
        │   │   main-state.ts
        │   │
        │   └───main-state
        │           time-intent.ts
        │
        └───utterances
                cancel-intents.ts
                invoke-generic-intent.ts
                small-talk-intents.ts
{
  "en": {
    "entities": {},
    "translation": {
      "helpState": {
        "showFaqIntent": "I can't show my FAQ yet."
      },
      "mainState": {
        "timeIntent": "It's chatbot time.",
        "testIntent": "Yep, I'm here :)",
        "sportResultsIntent": "I don't know. I'm not interested in human sports and there's not bot league, yet."
      }
    },
    "utterances": {
      "cancelIntents": {
        "cancelGenericIntent": [
          "cancel"
        ],
        "stopGenericIntent": [
          "stop"
        ]
      },
      "invokeGenericIntent": [],
      "small-talkIntents": {
        "helloIntent": [
          "Hello"
        ],
        "whatsYourNameIntent": [
          "What's your name"
        ]
      }
    }
  }
}
import { PlatformGenerator } from "assistant-source";
const entities: PlatformGenerator.CustomEntityMapping = {};
export = entities;
export const helpState = {
showFaqIntent: "I can't show my FAQ yet.",
};
export default {
testIntent: "Yep, I'm here :)",
sportResultsIntent: "I don't know. I'm not interested in human sports and there's not bot league, yet.",
};
export default {
cancelGenericIntent: ["cancel"],
stopGenericIntent: ["stop"],
};
export const helloIntent = ["Hello"];
export const whatsYourNameIntent = ["What's your name"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment