【问题标题】:BotFramework - How to pass the language from the DirectLine APIBotFramework - 如何从 DirectLine API 传递语言
【发布时间】:2016-09-01 04:58:06
【问题描述】:

我正在用两种语言(en、es)编写一个机器人,这将始终通过 DirectLine API 访问。

documentation 说:

本地化语言由当前线程的 CurrentUICulture 和 CurrentCulture 决定。

从 DirectLine API 将语言传递给 BOT 的正确方法是什么,可以通过 CurrentCulture 获取?

【问题讨论】:

    标签: botframework


    【解决方案1】:

    我还没有找到合适的方法,但我使用了一种解决方法。

    当您为用户提供 ID 时,请添加文化。像这样:

    id: 'en-'+ idGeneratedByYou
    

    然后从控制器:

    var culture = activity.From.Id.Split('-')[0];
    

    最后,做一个切换,取决于它是 en 还是 es:

    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-ES");
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-ES");
    

    我知道这不是最好的方法,但也许对你有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多