3

I'm building an Ember application which started using the ember-skeleton (which means I'm using Rake Pipeline as my build toolchain). I'm using ember-i18n, and that constantly throws warnings about not having the CLDR.pluralForm function.

I've added the CLDR plural functions which ember-i18n uses to the app/vendor/ directory and added that file to my Assetfile. I've verified that the code is included in my app.js before the ember-i18n code. I've also added the appropriate require lines in my main.js:

require('plurals');
require('ember-i18n');

Still, ember-i18n is giving warnings. This is the code where it's happening:

if (typeof CLDR !== "undefined" && CLDR !== null) {
  pluralForm = CLDR.pluralForm;
}

if (pluralForm == null) {
  Ember.Logger.warn("CLDR.pluralForm not found. Em.I18n will not support count-based inflection.");
}

How do I make sure CLDR is defined in my app?

hippietrail
  • 15,848
  • 18
  • 99
  • 158
pjmorse
  • 9,204
  • 9
  • 54
  • 124
  • Can you put together a simple fiddler to demonstrate the problem? – SciSpear Aug 12 '12 at 17:03
  • I'm not sure a jsfiddle will actually clarify this, because I *thought* the issue was with how I required the library. However, I tried and it was illuminating. This works: http://jsfiddle.net/pjmorse/SWcaX/ (check the console for warnings; I don't get any) and this doesn't: http://jsfiddle.net/pjmorse/VdwtK/ (You'll see a warning in the console.) The difference is the version of Ember: 1.0pre works, my few-weeks-old edge version doesn't. – pjmorse Aug 13 '12 at 14:43
  • Also, upgrading my app to Ember 1.0pre does not make the warning go away, the way it does in jsfiddle. – pjmorse Aug 15 '12 at 20:22

1 Answers1

3

Because no-one else has, I will suggest a few things I might look at if I were debugging the problem myself.

If the message you see in your site is the same as in the fiddler, it is due to the files just load out of order. Pretty much "plural" must load before the "i18n" plugin. If you flip the order of the linked files it will work (I forked the error-ing example).

I would try validating I am wrong by throwing some debugger; statements into each file to see which actually gets loaded first on the browser.

Because of your require('plurals') I am going to assume you are using requirejs (github is down for maintenance so I can't actually examine ember-skeleton at the moment... so this might get an edit in the future). If this assertion is true, you need to declare that 'plurals' is a dependency of 'i18n'.

"If you do not express the dependencies, you will likely get loading errors since RequireJS loads scripts asynchronously and out of order for speed." - RequireJS API

This means you probably will end up wrapping the two calls into one, adding a define or making a "shim"; these (and more) examples can be found on the RequireJS site.

Sorry if this does not help you but without seeing it actually broken; it is hard for me to debug the problem.

EDIT: Looking at the ember-skeleton, I don't see requireJS. I have never used rake (we ended up writing our pipeline in nodeJS) so I am not quite sure if you were actually trying to concat the files with require "blaw" in rake or if you actually trying to use both.... So now I assume this answer might not be super helpful.

SciSpear
  • 2,008
  • 18
  • 18