gadicc / meteor-messageformat

MessageFormat i18n support for Meteor, with reactive templates
55 stars 22 forks source link

[V2] Translations not available on remote systems (dev/test environment) #226

Open Sabst opened 8 years ago

Sabst commented 8 years ago

I have been using the package without any problem on my dev systems (same system as the server). Now, I'm testing remotely and the translations are not available.

msgfmt.init seems to be correctly called, at least as far as I can see from the traces.

On the systems that fail, in the mf function, I see that mfPkg.strings and mfPkg.compiled only contain the default locale. When I go to /translate, all the languages and translations appear correctly.

The problem is that the dev server is started with default parameters (localhost) and apparently the translations are loaded using the localhost address too (!). See Meteor.absoluteUrl()... When I access from a remote browser, this (silently) fails.

If I start the server with -p<myIP>:3000, then the translations are available.

So, it looks like the address used to download the translations should be checked as well as the error logging (maybe the init should fail if translations download has a network error).

In addition to error handling - or a fix solving the issue - this could be a documentation item too... but other remote functions - like ddp - work ok so there must be a way to use the right server without more config.

gadicc commented 8 years ago

Yes, you're right, in the code that handles this, on line 228, there's a TODO there that I should report if this doesn't work! Will get on that.

As you noticed though, the routine itself uses Meteor.absoluteUrl(), which "should be" correct. If it's not, this can affect a lot more than just msgfmt. I'm surprised DDP still works, and while we could try figure out what Meteor is doing, it really is super super important to correctly set your ROOT_URL environment for deployments, as a lot of things rely on this.

I'm hoping to get to the other two issues later today. Either way let's leave this open until I've put a better error message in.