dongying7667 2015-07-16 21:38
浏览 47
已采纳

统一ZF2 Translator和AngularJS本地化

I built an application that uses ZF2 for authentification, routing, error pages etc., but the core functionalities on each view are implemented in AngularJS. The whole thing is localized, but in 2 seperate instances:

We have the ZF2 Translator, configured in module.config.php

'translator' => array(
    'locale' => 'de_DE',
    'translation_file_patterns' => array(
        array(
            'type'     => 'phparray',
            'base_dir' => __DIR__ . '/../language',
            'pattern'  => '%s.php',
        ),
    ),
),

containing key=>value pairs like 'app.frontend.title' => 'Title'.

And the Angular-Translate module, configured by

$translateProvider.useStaticFilesLoader({
    prefix: '/lang/',
    suffix: '.json'
});

containing a nested JSON object like {'app': {'buttons': {'send': 'Send now'}}}'

The PHP part contains some headlines, content for <title>, navigation,... pretty much everything that is displayed outside of my AngularJS apps. The Angular-JSON contains l10n for a lot of buttons, dialogs etc.

Is there a possibility to unify these two? Doesn't matter if I access the AngularJS json file from the php script or the other way round (get the .json dynamically served by PHP for Angular). But I can't figure out how to read JSON for the ZF2 Translator.

  • 写回答

1条回答 默认 最新

  • dongna2498 2015-07-16 22:22
    关注

    Why would have you have some translations handled by PHP and some others by Angular JS? Couldn't you get rid of the ZF2 Translator?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题