meteor-translator icon indicating copy to clipboard operation
meteor-translator copied to clipboard

cordova support

Open dpwoert opened this issue 11 years ago • 7 comments

When building for Cordova I get the same error as issue #8. Have you tried running Cordova yet?

Error I'm getting:

(android:http://10.0.2.15:25010/packages/nemo64_translator.js:1312) Uncaught TypeError: Cannot call method 'hasOwnProperty' of undefined

dpwoert avatar Oct 07 '14 20:10 dpwoert

I can confirm that the tests fail when run in cordova on andoid. It seems like, that the files can't be loaded but that is a different error than you have there (i guess).

But I got to admit that I'm tapping in the dark there, I don't know how to debug in that environment.

What I know is that a request using meteors http interface to packages/local-test:nemo64:translator/test/namespace.de_DE.json fails.

Nemo64 avatar Oct 12 '14 13:10 Nemo64

Ok nevermind, this is related to a change meteor made a with the : in an url. Replacing that with an _ fixes the file problem. However that's only related to translation files and packages and now all tests run perfectly fine. Can you tell me a little more about the problem?

Nemo64 avatar Oct 12 '14 15:10 Nemo64

Also tried to run on iOS, but this also fails with the following stack trace:

Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined nemo64_translator.js?e40da14151b08dccd158290d90fcab780e12c251:1312
_.extend._init nemo64_translator.js?e40da14151b08dccd158290d90fcab780e12c251:1312
Namespace nemo64_translator.js?e40da14151b08dccd158290d90fcab780e12c251:387
Namespace.instance nemo64_translator.js?e40da14151b08dccd158290d90fcab780e12c251:404
(anonymous function) nemo64_translator.js?e40da14151b08dccd158290d90fcab780e12c251:750
Tracker.nonreactive tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:502
_.extend.use nemo64_translator.js?

I tried to use the most recent version on Github instead of Atmosphere, but no success. Are you sure language files are added to the Cordova build?

To debug in Cordova simply use console.log when simulating, this wil end up in your terminal :).

dpwoert avatar Oct 13 '14 18:10 dpwoert

The project I made this package for is too outdated for cordova and my newest project doesn't use translations yet. I only know that the test succeed and they require translations files. Of corse I don't know how heavy the difference between tinytest and release is.

Is this urgent? Because I don't have that much time on my hand right now.

Nemo64 avatar Oct 14 '14 14:10 Nemo64

Well... I tested loading the project without Translator in Cordova, it wil then fail on other dependencies. So I don't know if Translator just doesn't work or that it crashed because of other packages. Just waiting on more updates from other packages then I gues :)

dpwoert avatar Oct 14 '14 19:10 dpwoert

@dpwoert and @Nemo64 this is because of the translator :) i have the same issue here. I am working on this. Any news from you @dpwoert ?

nerdmed avatar Jul 02 '15 23:07 nerdmed

@dpwoert ok i think i found it. The reason is the dependency on a server request. On startup from bundle there is no request Header from the server ? Or the header injection by Inject Initial does not work for ios on first start.

It will fail in Namespace-client.js on

namespaces.hasOwnProperty

as in line 24, the Injected.obj(...) call will return undefined

var namespaces = Injected.obj('translator-namespaces') 

I could fix it with a quick HACK for now:

  • take a local copy of the package into your project

  • replace line 24 in Namespace-client.js with:

    var namespaces = Injected.obj('translator-namespaces') || Meteor.settings &&  Meteor.settings.public &&  Meteor.settings.public.translatorNamespaces;
    
  • add to settings to your meteor app add include the languages manually.

{  
    "public": {
        "translatorNamespaces": {
            "pathToYour/languageFile": {
              "de_DE": 1,
              "en_US": 1
            },
            "language/usersV01": {
              "de_DE": 1,
              "en_US": 1
            }
        }
    }
}
  • you can get the JSON object by running on your desktop machine the following steps
  1. add this package:
meteor add meteorhacks:inject-initial
  1. Open in your browser locally and run in the console:
 JSON.stringify(  Injected.obj('translator-namespaces')  )
  1. Copy the output to your settings :)

@Nemo64 do you know a way to automate this to the build process? If you have any idea I could do the rest. As every i18n package for meteor is missing the feature to work on initial start and without server connection this would be really a nice feature!

nerdmed avatar Jul 03 '15 01:07 nerdmed