dongren1986 2013-11-20 11:49
浏览 529
已采纳

使用Angular-translate进行参数格式化

Lately I've encountered this library, I looks very promising, and I understand that it's widely used and supports all kinds of neat features such as asynchronous loading on languages JSONs, using local storage, etc etc.

One thing that is quite trivial though, is string formatting \ passing parameters to the translate filter, doesn't seem to be supported: for instance: 'You have successfully singed in with %S'

A certain param filter, such as:

$translateProvider.translations('en', {
AUTH_SUCCESS : '%s, You have successfully singed in with %s'
}

HTML:

<span>{{AUTH_MESSAGE | translate : [$scope.name, $scope.network]}}<span>

Is there anything that can serve that kind of purpose in this library?

  • 写回答

2条回答 默认 最新

  • dtv8189 2014-01-17 08:37
    关注

    Well, it is documented in the main docs, you just have to take a look at the main docs

    {
        'AUTH_SUCCESS' : '{{ name }}, You have successfully singed in with {{ network }}'
    }
    

    .

    <span>{{AUTH_MESSAGE | translate : '{name : $scope.name, network : $scope.network}' }}</span>
    

    Check out this one: http://angular-translate.github.io/docs/#/guide/06_variable-replacement

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料