Nemo64 / meteor-translator

a feature rich internationalization (i18n) package for meteor with usage of the Unicode Common Locale Data Repository
MIT License
15 stars 4 forks source link

cordova support #9

Open dpwoert opened 9 years ago

dpwoert commented 9 years ago

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
Nemo64 commented 9 years ago

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 commented 9 years ago

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?

dpwoert commented 9 years ago

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 :).

Nemo64 commented 9 years ago

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.

dpwoert commented 9 years ago

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 :)

nerdmed commented 8 years ago

@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 commented 8 years ago

@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:

{  
    "public": {
        "translatorNamespaces": {
            "pathToYour/languageFile": {
              "de_DE": 1,
              "en_US": 1
            },
            "language/usersV01": {
              "de_DE": 1,
              "en_US": 1
            }
        }
    }
}
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!