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

Package loads languages from server, not from Cordova's local storage #3

Open
derwaldgeist opened this issue Jan 25, 2016 · 8 comments

Comments

@derwaldgeist
Copy link

If this package is used on a Cordova device, it still tries to load the language file from the server instead of the local storage (http://meteor.local). This has two effects:

  1. The language switch does not work if the device is in offline mode
  2. Even if the device is in online mode, it throws an error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://meteor.local' is therefore not allowed access.

This is because the Meteor server is considered as being a different location than the local storage and it does not send a CORS compliant header.

I would have expected that this package is intended to load the language files from the local Cordova filesystem, using the http://meteor.local location. Otherwise, it does not make much sense to me to store the files locally. Did I get something wrong?

@IstoraMandiri
Copy link
Contributor

That's strange behaviour. I've just tested with cordova using cdn_path: 'i18n' and it seems to be loading as expected.

Request URL:http://meteor.local/i18n/de.json
Request Method:GET

Are you sure that issue #2 was solved using /i18n instead, as it seems to be working with i18n for me? I've pushed an example app to show this.

Failing that, could you provide a reproduction?

Thanks!

IstoraMandiri added a commit that referenced this issue Feb 3, 2016
@miri-am
Copy link

miri-am commented Feb 17, 2016

same for me

XMLHttpRequest cannot load http://10.2.83.191:3001/i18n/de.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://meteor.local' is therefore not allowed access.

shouldnt the file from /public/i18n be requested?

@IstoraMandiri
Copy link
Contributor

@miri-am what is your cdn_path, and do you have a reproduction?

Also what version of tap:i18n ?

thanks

@miri-am
Copy link

miri-am commented Feb 17, 2016

Nevermind, now it works again. I am not sure what the reason was (might have been an extra /before the paths. This one is working now (with tap:i18n 1.7.0). Thanks for responding.

{
    "helper_name": "_",
    "supported_languages": ["de", "en"],
    "i18n_files_route": "i18n",
    "cdn_path": "i18n",
    "preloaded_langs": ["*"]
}

@IstoraMandiri
Copy link
Contributor

Excellent - good to hear. It may be that tap:i18n was below 1.6.something, which also didn't support cordova.

@miri-am
Copy link

miri-am commented Feb 17, 2016

little revision. My config from above throws a jsonerror outside of cordova. Seems like I need to use the following config:

{
    "helper_name": "_",
    "supported_languages": ["de", "en"],
    "i18n_files_route": "/i18n",
    "cdn_path": "i18n",
    "preloaded_langs": ["*"]
}

The cdn_path needs to be without the /but the i18n_files_route needs it. Otherwise it will work either in Cordova or in Web but not in both.

@IstoraMandiri
Copy link
Contributor

the i18n_files_route should be ignored if cdn_path if set -- does it make a difference if ou remove i18n_files_route ?

@miri-am
Copy link

miri-am commented Feb 17, 2016

you are correct. Seems to be working after removal. Thanks!

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