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?

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器