Skip to content

Commit

Permalink
Add setting to configure i18n for Smarti widget (RocketChat#308)
Browse files Browse the repository at this point in the history
* Add setting to configure i18n for Smarti widget

* add exhausting description for the translation object
  • Loading branch information
mrsimpson authored Apr 19, 2018
1 parent b1b2ce3 commit 57e6674
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/assistify-ai/client/views/app/tabbar/smarti.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ Template.AssistifySmarti.onRendered(function() {
},
lang: localStorage.getItem('userLanguage').split('-')[0]
};

//propagate i18n - support formatted strings while doing that
const i18nSetting = RocketChat.settings.get('Assistify_AI_Smarti_Widget_i18n');
const i18n = i18nSetting.search('\n') > -1 ? JSON.parse(i18nSetting) : i18nSetting;
if (i18n) {
smartiOptions.i18n = i18n;
}

console.debug('Initializing Smarti with options: ', JSON.stringify(smartiOptions, null, 2));
instance.smarti = new window.SmartiWidget(instance.find('.smarti #widgetContainer'), smartiOptions);
}
Expand All @@ -74,14 +82,14 @@ Template.AssistifySmarti.onRendered(function() {
Template.AssistifySmarti.helpers({
isLivechat() {
const instance = Template.instance();
return ChatSubscription.findOne({rid: instance.data.rid}).t === 'l';
return ChatSubscription.findOne({ rid: instance.data.rid }).t === 'l';
},
/**
This helper is needed in order to create an object which matches the actions bar importing parameters
*/
liveChatActions() {
const instance = Template.instance();
return {roomId: instance.data.rid};
return { roomId: instance.data.rid };
},
helpRequestByRoom() {
const instance = Template.instance();
Expand Down
7 changes: 7 additions & 0 deletions packages/assistify-ai/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ Meteor.startup(() => {
public: true,
i18nLabel: 'Assistify_AI_RocketChat_Webhook_Token'
});

this.add('Assistify_AI_Smarti_Widget_i18n', '', {
type: 'code',
public: true,
i18nLabel: 'Assistify_AI_Smarti_Widget_i18n',
i18nDescription: 'Assistify_AI_Smarti_Widget_i18n_Description'
});
});
};

Expand Down
16 changes: 16 additions & 0 deletions packages/rocketchat-i18n/i18n/assistifyAI.de.i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ Assistify_AI_Smarti_Domain: Smarti Client-Name
Assistify_AI_Smarti_Domain_Description: Trage hier den Smarti Client-Name ein, der zu dieser Rocket.Chat Instanz gehört.
Assistify_AI_Smarti_Auth_Token: Smarti Client-Token
Assistify_AI_Smarti_Auth_Token_Description: Trage hier den Smarti Client-Token ein, damit sich Rocket.Chat gegenüber Smarti authentifizieren kann.
Assistify_AI_Smarti_Widget_i18n: Texte des Smarti-Widgets
Assistify_AI_Smarti_Widget_i18n_Description: |
Ein JSON-Objekt, mit dem die Übersetzungen definiert werden.
Mögliche Werte:
- widget.conversation.answer.title
- widget.conversation.answer.title_msg
- widget.latch.answer.title
Beispiel:
{
"widget.conversation.answer.title": {
"de":"Ich habe eine passende Konversation gefunden:",
"en":"I found a similar conversation:"
}
}
Assistify_AI_Widget_Posting_Type: Posting-Verhalten des Widgets
Assistify_AI_Widget_Posting_Type_Description: Wähle wie die Vorschläge von Smarti in den Chat übernommen werden sollen.
Assistify_AI_Widget_Posting_Type_SuggestText: Plain Text vorschlagen
Expand Down
16 changes: 16 additions & 0 deletions packages/rocketchat-i18n/i18n/assistifyAI.en.i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ Assistify_AI_Smarti_Domain: Smarti Client-Name
Assistify_AI_Smarti_Domain_Description: Enter your Smarti Client-Name, that belongs to this Rocket.Chat instance.
Assistify_AI_Smarti_Auth_Token: Smarti Client-Token
Assistify_AI_Smarti_Auth_Token_Description: Enter your Smarti Client-Token, to authorize Rocket.Chat to access Smarti.
Assistify_AI_Smarti_Widget_i18n: Texts of the Smarti-Widget
Assistify_AI_Smarti_Widget_i18n_Description: |
A JSON-object which defines the translation strings.
Possible values:
- widget.conversation.answer.title
- widget.conversation.answer.title_msg
- widget.latch.answer.title
Example:
{
"widget.conversation.answer.title": {
"de":"Ich habe eine passende Konversation gefunden:",
"en":"I found a similar conversation:"
}
}
Assistify_AI_Widget_Posting_Type: Widget posting behaviour
Assistify_AI_Widget_Posting_Type_Description: Select how to send Smarti suggestions.
Assistify_AI_Widget_Posting_Type_PostRichText: post rich text
Expand Down

0 comments on commit 57e6674

Please sign in to comment.