2015年5月21日 星期四

[Groovy & Grails] 在Grails中使用Microsoft Translate [未完]

在寫專題的時候因為要用到翻譯的功能,因此在這邊做個記錄
Grails Plugin:https://grails.org/plugin/translate
Github:https://github.com/boatmeme/grails-translate
  1. 先去https://grails.org/plugin/translate 這邊安裝 Grails 的 plugin。在Grails 2.3以上的版本,好像就不能用install-plugin這個指令去安裝plugin了,因此要設定 grails-app/conf/BuildConfig.groovy ,把剛剛網址裡面寫的 Dependency 和 Custom Repositories 設定好就可以了。
  2. 接著去這裡申請一個Client ID。(可以參考這篇教學)
  3. 接著設定 grails-app/conf/BuildConfig.groovy
    translate.microsoft.clientId = 'chatroom_project' // Windows Azure Marketplace Client ID (REQUIRED)
    translate.microsoft.clientSecret = 'HhV4U2WXfimyl/RfVrsViCqVdkvNcuvI/b3mtNyX+kM' // Windows Azure Marketplace Client Secret (REQUIRED)
    translate.translation.cache.maxSize = 1000 // Maximum size of the LRU Cache for Translations
    translate.detection.cache.maxSize = 1000 // Maximum size of the LRU Cache for Language Detection


  4. 設定完之後可以用http://localhost:8080/chatroom/translate/index測試看看能不能用
    (有顏色的部分是APP的名字)
    (中文可以轉英文)
         (英文不能轉中文OAO)

沒有留言:

張貼留言