Internationalization
The I18n library is already integrated in Kogno, so the development of a multi-language chatbot is relatively easy.
Configuration
Default locale
The default locale can be set editing the configuration config.default_locale
in config/application.rb
file.
Setup locales
Kogno will load automatically all .yml
files located in the folder config/locales/
.
All necessary locales files can be created. Being one for each language supported by the chatbot.
Examples
English: config/locales/en.yml
config/locales/en.yml
Spanish: config/locales/es.yml
config/locales/es.yml
If in value there is more than one option, like in the example above, hello
with options "Hello" and "Hi", Kogno will randomly return a single one.
This would help create a less monotonous conversation.
Usage
The global method t()
(short for I18n.t()
) can be called anywhere in a project's code.
t(key=String|Symbol, **interpolation)
t(key=String|Symbol, **interpolation)
Example
Read more examples of I18n
usage in the official documentation.
User Locale
By default, the locale of a user starting a conversation for first time will be the one defined in the chatbot settings, if the platform has not included it in the webhook.
But this can be changed by calling the set_locale()
from User
model.
Last updated