Giter Site home page Giter Site logo

Comments (3)

RafaelCosman avatar RafaelCosman commented on July 30, 2024

@rodrigoalviani, great point. This is important.

from botkit.

peterswimm avatar peterswimm commented on July 30, 2024

Created a new dev4slack channel, #botkit-localization to discuss this Feature Request. If you are interested, please join the conversation!

from botkit.

znat avatar znat commented on July 30, 2024

For now I am doing the following (with i18n-node):

At bot initialization:

var i18n = require('i18n');
i18n.configure({...});
var bot = controller.spawn({...});
bot.i18n = i18n;

I wrote a middleware to add facebook messenger's user_profile to the message object:

{ text: 'ce soir',
  user: '123456789',
  channel: '/#QpmoHYNhZlvOzUXiAAAB', // socket id 
  timestamp: 1484084415264,
  user_profile: 
   { 
     first_name: 'Nathan',
     last_name: 'Zylbersztejn',
     locale: 'fr_CA',
     profile_pic: '<url>',
     timezone: -5,
     gender: 'male',
     is_payment_enabled: true,
     id: '123456789' },
  entities: {...} 
}

In the conversation:

 bot.createConversation(message, function (err, convo) {
        convo.setVar("user_profile",message.user_profile);
        convo.addMessage({
            text: bot.i18n.__({phrase:'reminder_confirmation',locale:convo.vars.user_profile.locale}),
            action: 'completed'
        },'set_reminder');
       // rest of convo...
}

It would make sense to have the user profile accessible in the convo (which is also semantically defined by the people who run it). This would avoid setting the variable and we could find a way to make i18n aware of it to avoid passing the locale at every translation.

from botkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.