You are currently viewing Adding Languages Name in SUSI Skill CMS

Adding Languages Name in SUSI Skill CMS

The SUSI skill CMS is an editor to write and edit skill easily. It follows an API-centric approach where the SUSI server acts as API server and a web front-end  act as the client for the API and provides the user interface. A skill is a set of intents. One text file represents one skill, it may contain several intents which all belong together. All the skills are stored in SUSI Skill Data repository and the schema is Models -> Groups -> Languages -> Skill -> Intents.

To get the list of all the languages stored in Susi Skill Data repository, we used the endpoint provided by SUSI Server.

    public UserRole getMinimalUserRole() { return UserRole.ANONYMOUS; }

The getMinimalBaseRole method tells the minimum Userrole required to access this servlet it can also be ADMIN, USER. In our case it is Anonymous. A User need not to log in to access this endpoint.

    public ServiceResponse serviceImpl(Query call, HttpServletResponse response, Authorization rights, final JsonObjectWithDefault permissions) {
        String model_name = call.get("model", "general");
        File model = new File(DAO.model_watch_dir, model_name);
        String group_name = call.get("group", "Knowledge");
        File group = new File(model, group_name);
        JSONObject json = new JSONObject(true);
        json.put("accepted", false);
        String[] languages = group.list((current, name) -> new File(current, name).isDirectory());
        JSONArray languagesArray = new JSONArray(languages);
        json.put("languagesArray", languagesArray);
        json.put("accepted", true);
        return new ServiceResponse(json);

One can access based on model and group. We can get the required parameters through call.get() method where first parameter is the key for which we want to get the value and second parameter is the default value. We make a json array of languages ISO codes and send it as a response for this endpoint.

Next, to display the actual name we used a ISO-639-1 npm package for language name translation from their respective codes.

console.log(ISO6391.getName('zh')) // 'Chinese'
console.log(ISO6391.getNativeName('zh')) // '中文'

Next we use getAlllanguages.json endpoint of Susi_server

if (languages.length === 0) {
                url: '',
                jsonpCallback: 'pc',
                dataType: 'jsonp',
                jsonp: 'callback',
                crossDomain: true,
                success: function (data) {

                    data = data.languagesArray
                    this.setState({ languages: data });
                    for (let i = 0; i < data.length; i++) {
                        if (ISO6391.getNativeName(data[i])) {
                                primaryText={ISO6391.getNativeName(data[i])} />);
                        else {
                            languages.push(<MenuItem value={data[i]}
                                                    primaryText={'Universal'} />);

and make an Ajax network call to get the ISO codes from the above endpoints. We parses the response in data object, using ISO6391 npm package we added the native language name in the drop down for the languages. We defined a Universal language with code ‘xx’, for skills which is related to mathematical and computational problems.

This is how we added language’s native form in Susi skill CMS, To add more skills or modify the existing ones visit For more information and complete code take a look at Susi server and Susi_Skill_cms and join gitter chat channel for discussions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.