我遇到了一个问题,ember-i18n可以与运行在开发环境中的ember-cli服务器一起使用。但是当我设置--environment production时,我得到了以下错误:
Error: The default Ember.I18n.compile function requires the full Handlebars. Either include the full Handlebars or override Ember.I18n.compile.
发生该错误是因为ember-cli在生产环境中包含Handlebars production。这个问题有解决方案吗?
我想我需要预编译这些翻译。
发布于 2014-07-08 19:12:09
解决这个问题的一种方法是配置ember-cli以包含生产环境中的完整handlebars版本:
app.import({
development: 'vendor/handlebars/handlebars.js',
production: 'vendor/handlebars/handlebars.js'
});一个缺点是(大得多)的库包含在构建中,仅用于我的翻译。我一直在寻找一种方法来预编译我的翻译。
发布于 2014-07-09 02:56:52
在使用ember-i18n时,没有办法导入完整的把手。但是,您不需要为开发和生产指定相同的字符串导入。只需将此代码添加到您的Brocfile中:
app.import('vendor/handlebars/handlebars.js');我有完全相同的问题,这是Stefan Penner建议的解决方案。https://github.com/stefanpenner/ember-cli/pull/675#issuecomment-47431195。对我来说工作得很好。但有一件事需要注意,由于某种原因,我将import语句作为第一个导入语句。当它是最后一个时,它似乎不起作用。不过,我没有尝试任何介于两者之间的地方,也没有尝试调试这个问题。
https://stackoverflow.com/questions/24628796
复制相似问题