Skip to content

Commit

Permalink
Merge pull request #235 from Hexastack/feat/use-i18n-ns
Browse files Browse the repository at this point in the history
feat(frontend): add i18n namespace + remove setting help & id
  • Loading branch information
marrouchi authored Oct 18, 2024
2 parents 57a04da + 6249c51 commit c902a8c
Show file tree
Hide file tree
Showing 31 changed files with 347 additions and 208 deletions.
2 changes: 1 addition & 1 deletion api/src/chat/controllers/block.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class BlockController extends BaseController<
plugin: p.id,
args: p.settings.reduce(
(acc, setting) => {
acc[setting.id] = setting.value;
acc[setting.label] = setting.value;
return acc;
},
{} as { [key: string]: any },
Expand Down
2 changes: 1 addition & 1 deletion api/src/plugins/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface CustomBlocks {}
type ChannelEvent = any;
type BlockAttrs = Partial<BlockCreateDto> & { name: string };

export type PluginSetting = Omit<Setting, 'createdAt' | 'updatedAt'>;
export type PluginSetting = Omit<Setting, 'id' | 'createdAt' | 'updatedAt'>;

export type PluginBlockTemplate = Omit<
BlockAttrs,
Expand Down
10 changes: 1 addition & 9 deletions api/src/setting/schemas/setting.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/

import { Prop, Schema, SchemaFactory, ModelDefinition } from '@nestjs/mongoose';
import { Transform } from 'class-transformer';
import { ModelDefinition, Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { IsArray, IsIn } from 'class-validator';

import { BaseSchema } from '@/utils/generics/base-schema';
Expand Down Expand Up @@ -46,13 +45,6 @@ export class Setting extends BaseSchema {
@Prop({ type: JSON, default: {} })
config?: Record<string, any>;

@Prop({
type: String,
default: '',
})
@Transform(({ obj }) => obj.help || undefined)
help?: string;

@Prop({
type: Number,
default: 0,
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"eazychart-css": "^0.2.1-alpha.0",
"eazychart-react": "^0.8.0-alpha.0",
"hexabot-chat-widget": "*",
"i18next-http-backend": "^2.6.2",
"next": "^14.2.13",
"next-transpile-modules": "^10.0.1",
"normalizr": "^3.6.2",
Expand Down
13 changes: 13 additions & 0 deletions frontend/public/locales/en/chatbot_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": {
"chatbot_settings": "Chatbot"
},
"label": {
"global_fallback": "Enable Global Fallback?",
"fallback_message": "Fallback Message"
},
"help": {
"global_fallback": "Global fallback allows you to send custom messages when user entry does not match any of the block messages.",
"fallback_message": "If no fallback block is selected, then one of these messages will be sent."
}
}
18 changes: 18 additions & 0 deletions frontend/public/locales/en/contact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"title": {
"contact": "Contact Infos"
},
"label": {
"contact_email_recipient": "Contact Email Recipient",
"company_name": "Your company's name",
"company_phone": "Phone number",
"company_email": "Email address",
"company_address1": "Address",
"company_address2": "Address 2",
"company_city": "City",
"company_zipcode": "Zipcode",
"company_state": "State",
"company_country": "Country"
},
"help": {}
}
28 changes: 28 additions & 0 deletions frontend/public/locales/en/live-chat-tester.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": {
"live-chat-tester": "Live Chat Tester"
},
"label": {
"verification_token": "Verification Token",
"allowed_domains": "Allowed Domains",
"start_button": "Enable `Get Started`",
"input_disabled": "Disable Input",
"persistent_menu": "Display Persistent Menu",
"greeting_message": "Greeting Message",
"theme_color": "Widget Theme",
"theme_color_options": {
"orange": "Orange",
"red": "Red",
"green": "Green",
"blue": "Blue",
"dark": "Dark"
},
"window_title": "Chat Window Title",
"avatar_url": "Chatbot Avatar URL",
"show_emoji": "Enable Emoji Picker",
"show_file": "Enable Attachment Uploader",
"show_location": "Enable Geolocation Share",
"allowed_upload_size": "Max Upload Size (in bytes)",
"allowed_upload_types": "Allowed Upload Mime Types (comma separated)"
}
}
16 changes: 16 additions & 0 deletions frontend/public/locales/en/nlp_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": {
"nlp_settings": "NLU Engine"
},
"label": {
"provider": "Provider",
"token": "API Access Token",
"endpoint": "API Endpoint URL",
"threshold": "Fallback Threshold"
},
"help": {
"endpoint": "NLU (Natural Language Understanding) API URL (Depends on the provider).",
"token": "Every API request must contain an Authorize HTTP header with a token.",
"threshold": "Threshold above which the chatbot will use its prediction (min=0 & max=1)"
}
}
28 changes: 28 additions & 0 deletions frontend/public/locales/en/offline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": {
"offline": "Web Channel"
},
"label": {
"verification_token": "Verification Token",
"allowed_domains": "Allowed Domains",
"start_button": "Enable `Get Started`",
"input_disabled": "Disable Input",
"persistent_menu": "Display Persistent Menu",
"greeting_message": "Greeting Message",
"theme_color": "Widget Theme",
"theme_color_options": {
"orange": "Orange",
"red": "Red",
"green": "Green",
"blue": "Blue",
"dark": "Dark"
},
"window_title": "Chat Window Title",
"avatar_url": "Chatbot Avatar URL",
"show_emoji": "Enable Emoji Picker",
"show_file": "Enable Attachment Uploader",
"show_location": "Enable Geolocation Share",
"allowed_upload_size": "Max Upload Size (in bytes)",
"allowed_upload_types": "Allowed Upload Mime Types (comma separated)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@
"offline": "Web Channel",
"twitter": "Twitter",
"dimelo": "Dimelo",
"contact": "Contact Infos",
"chatbot_settings": "Chatbot",
"nlp_settings": "NLU Provider",
"contact_infos": "Contact Infos",
"event_log": "Events Log",
"log_entry": "Log entry",
"dashboard": "Dashboard",
Expand Down Expand Up @@ -471,37 +467,6 @@
},
"languages": "Available Languages",
"default_lang": "Default Language",
"default_lang_options": {
"fr": "Français",
"en": "English",
"ar": "Arabic",
"tn": "Tunisian"
},
"token": "API Access Token",
"endpoint": "API Endpoint URL",
"threshold": "Fallback Threshold",
"from": "Sender e-mail",
"mailer": "Mailer",
"mailer_options": {
"sendmail": "Sendmail",
"smtp": "SMTP Server"
},
"host": "SMTP Host",
"port": "Port",
"secure": "Use SSL ?",
"auth_user": "User",
"auth_pass": "Password",
"contact_email_recipient": "Contact Email Recipient",
"company_name": "Your company's name",
"company_phone": "Phone number",
"company_email": "Email address",
"company_address1": "Address",
"company_address2": "Address 2",
"company_city": "City",
"company_zipcode": "Zipcode",
"company_state": "State",
"company_country": "Country",
"global_fallback": "Enable Global Fallback?",
"secret": "Secret",
"verification_token": "Verification Token",
"allowed_domains": "Allowed Domains",
Expand All @@ -524,21 +489,6 @@
"show_location": "Enable Geolocation Share",
"allowed_upload_size": "Max Upload Size (in bytes)",
"allowed_upload_types": "Allowed Upload Mime Types (comma seperated)",
"tw_consumer_key": "Consumer Key",
"tw_consumer_secret": "Consumer Secret",
"tw_access_token": "Access Token",
"tw_access_token_secret": "Access Token Secret",
"tw_greeting_text": "Greeting Text",
"d_api_url": "API URL",
"d_access_token": "API Access Token",
"d_verify_token": "API Verify Token",
"d_attachment_fallback_id": "Attachment Fallback ID",
"d_url_fallback": "URL Fallback",
"d_supported_domain_id": "Supported Domain ID",
"d_agent_category_id": "Flow IDs when handed-over",
"d_admin_user": "On handover, assign to (admin user ID)",
"d_test_identities": "Identity IDs used for testing",
"d_supported_sources": "Supported Sources",
"channel": "Channel",
"entry": "Entry content",
"thumbnail": "Thumbnail",
Expand Down Expand Up @@ -673,11 +623,7 @@
"composer_input_disabled": "This means your bot can only be interacted with via the persistent menu, postbacks, buttons, and webviews.",
"get_started_button": "A bot's welcome screen can display a Get Started button. When this button is tapped, the Messenger Platform will send a postback event to your webhook (Payload = `GET_STARTED`).",
"greeting_text": "The greeting property of your bot's Messenger profile allows you to specify the greeting message people will see on the welcome screen of your bot. The welcome screen is displayed for people interacting with your bot for the first time.",
"global_fallback": "Global fallback allows you to send custom messages when user entry does not match any of the block messages.",
"fallback_message": "If no fallback block is selected, then one of these messages will be sent.",
"endpoint": "URL to which HTTP NLU requests are posted and that depends on the type of provider.",
"token": "Every API request must contain an Authorize HTTP header with a token.",
"threshold": "Threshold above which the chatbot will use its prediction (min=0 & max=1)",
"app_id": "Mandatory only if you intend to use Facebook Analytics",
"page_id": "Mandatory only if you intend to use Facebook Analytics",
"nlp_train": "You can train your chatbot by adding more examples",
Expand Down
13 changes: 13 additions & 0 deletions frontend/public/locales/fr/chatbot_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": {
"chatbot_settings": "Chatbot"
},
"label": {
"global_fallback": "Activer le message de secours global?",
"fallback_message": "Message de secours"
},
"help": {
"global_fallback": "Le message de secours global vous permet d'envoyer des messages personnalisés lorsque le message de l'utilisateur ne déclenche aucun bloc de message.",
"fallback_message": "Si aucun bloc de secours n'est spécifié, alors de ces messages sera envoyé."
}
}
18 changes: 18 additions & 0 deletions frontend/public/locales/fr/contact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"title": {
"contact": "Contact"
},
"label": {
"contact_email_recipient": "Email de contact du destinataire",
"company_name": "Le nom de votre entreprise",
"company_phone": "Tél.",
"company_email": "Adresse e-mail",
"company_address1": "Adresse",
"company_address2": "Adresse 2",
"company_city": "Ville",
"company_zipcode": "Code postal",
"company_state": "État/Province",
"company_country": "Pays"
},
"help": {}
}
28 changes: 28 additions & 0 deletions frontend/public/locales/fr/live-chat-tester.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": {
"live-chat-tester": "Testeur Live Chat"
},
"label": {
"verification_token": "Jeton de vérification",
"allowed_domains": "Domaines autorisés",
"start_button": "Activer `Démarrer`",
"input_disabled": "Désactiver la saisie",
"persistent_menu": "Afficher le menu persistent",
"greeting_message": "Message de bienvenue",
"theme_color": "Thème du widget",
"theme_color_options": {
"orange": "Orange",
"red": "Rouge",
"green": "Vert",
"blue": "Bleu",
"dark": "Sombre"
},
"window_title": "Titre de la fenêtre de chat",
"avatar_url": "Avatar du chatbot (URL)",
"show_emoji": "Activer le sélecteur d'Emojis",
"show_file": "Activer l'upload de fichiers",
"show_location": "Activer le partage de géolocalisation",
"allowed_upload_size": "Taille maximale de téléchargement (en octets)",
"allowed_upload_types": "Types MIME autorisés pour le téléchargement (séparés par des virgules)"
}
}
16 changes: 16 additions & 0 deletions frontend/public/locales/fr/nlp_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": {
"nlp_settings": "Serveur NLU"
},
"label": {
"provider": "Fournisseur",
"token": "Token d'accès à l'API",
"endpoint": "URL de l'API",
"threshold": "Seuil de repli"
},
"help": {
"endpoint": "URL vers laquelle les requêtes de NLU HTTP sont envoyées et qui dépend du fournisseur.",
"token": "Chaque requête vers l'API doit contenir un jeton d'authentification.",
"threshold": "Seuil en dessus duquel le chatbot va utiliser sa prediction (min=0 & max=1)"
}
}
28 changes: 28 additions & 0 deletions frontend/public/locales/fr/offline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": {
"offline": "Canal Web"
},
"label": {
"verification_token": "Jeton de vérification",
"allowed_domains": "Domaines autorisés",
"start_button": "Activer `Démarrer`",
"input_disabled": "Désactiver la saisie",
"persistent_menu": "Afficher le menu persistent",
"greeting_message": "Message de bienvenue",
"theme_color": "Thème du widget",
"theme_color_options": {
"orange": "Orange",
"red": "Rouge",
"green": "Vert",
"blue": "Bleu",
"dark": "Sombre"
},
"window_title": "Titre de la fenêtre de chat",
"avatar_url": "Avatar du chatbot (URL)",
"show_emoji": "Activer le sélecteur d'Emojis",
"show_file": "Activer l'upload de fichiers",
"show_location": "Activer le partage de géolocalisation",
"allowed_upload_size": "Taille maximale de téléchargement (en octets)",
"allowed_upload_types": "Types MIME autorisés pour le téléchargement (séparés par des virgules)"
}
}
Loading

0 comments on commit c902a8c

Please sign in to comment.