Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading languages with requirejs #148

Closed
rudym87 opened this issue Apr 4, 2016 · 16 comments
Closed

Loading languages with requirejs #148

rudym87 opened this issue Apr 4, 2016 · 16 comments

Comments

@rudym87
Copy link

rudym87 commented Apr 4, 2016

How can I load a language file in an AMD environment?
Currently trying to load languages.js or any single language file gives a No define call for... error.

@BenjaminVanRyseghem
Copy link
Owner

did you tried with the languages files in dist/languages/?

I think those one have an AMD wrapper

@rudym87
Copy link
Author

rudym87 commented Apr 4, 2016

Already tried, same error.

@BenjaminVanRyseghem
Copy link
Owner

On 4 Apr, 2016, at 17:32, rudym87 notifications@github.com wrote:

Already tried, same error.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub https://github.com/foretagsplatsen/numbro/issues/148#issuecomment-205352767

then I need to investigate 😄

which version do you use? have you tried several versions?

Thanks

@mmollick
Copy link
Contributor

mmollick commented Apr 4, 2016

It doesn't look like there's any existing AMD support, just CommonJS and basic script tag support.
It probably wouldn't be too difficult to add in AMD support. Though I haven't used requirejs in quite a while so I can't recall what all is needed, I think it's window.define.

@BenjaminVanRyseghem
Copy link
Owner

we use numbro in production in an AMD environment (not the latest numbro though).

Support is here

@rudym87
Copy link
Author

rudym87 commented Apr 5, 2016

I did some tests, and loading languages fails when enabling in requirejs config enforceDefine, which is mainly used to resolve some quirks of old IE versions.

Requirejs documentation doesn't state clearly if it applies to newer IE version too, so I don't really consider it a bug in numbro, i think i can safely disable enforceDefine in my case.

Anyway, for completeness' sake, here's a jsfiddle to repoduce it.

@BenjaminVanRyseghem
Copy link
Owner

Here is a working fiddle. Let's hope you find it useful 😄

@rudym87
Copy link
Author

rudym87 commented Apr 6, 2016

Numbro languages work fine even without shim, assuming they're required in the proper order.
Enabling enforceDefine still breaks your fiddle though.:smile:

@BenjaminVanRyseghem
Copy link
Owner

That's a bit cheating, but you can always do that

@BenjaminVanRyseghem
Copy link
Owner

can we close this?

@rudym87
Copy link
Author

rudym87 commented Apr 11, 2016

Yes, the "cheat" is fine, i'm closing this.

@rudym87 rudym87 closed this as completed Apr 11, 2016
@BenjaminVanRyseghem
Copy link
Owner

@rudym87 if you need it lees cheaty, we could introduce a map of imported lnaguages, so that you could have:

},
  shim: {
        'numbro-french': {
        deps: ['numbro'],
      exports: "numbro.importedLanguages['fr-FR']"
    }
  }

or similar

@rudym87
Copy link
Author

rudym87 commented Apr 11, 2016

That can be an interesting solution, it can be used for other checks unrelated to requirejs.

@BenjaminVanRyseghem
Copy link
Owner

could you create another issue for it? 😄

@rudym87
Copy link
Author

rudym87 commented Apr 11, 2016

Done!

@BenjaminVanRyseghem
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants