1

We use Cordova to make a native app from Sencha Touch, and at present I have run into a problem.

The application in question is localised to 26 different european markets. In the JS we use localised copy in the config objects of our views for readability and easy developing.

E.G

Ext.define('MyApp.view.Main', {
  extend: 'Ext.Panel',
  xtype: 'main',


  config: {
    title: MyApp.utils.Strings.getString('mainTitle')
  }
});

So the problem we are now having is with using the globalization plugin in Cordova. https://github.com/apache/cordova-plugin-globalization/blob/master/doc/index.md

The globalization method for getting the device language (we need to be as specific as French Belgium and so forth) is an async call. So by the time the result is received the Sencha JS has already been parsed and all the strings are returned as "undefined" as there was no locale code set when the config objects tried to obtain the copy.

What I was trying to do is delay Sencha running until I have gained the iso-code from Cordova so when the Sencha app loads and boots up it is has all the information needed.

I have tried changing the production.js microloader and the testing.js. However if I change this loaders so I can call the start of Sencha myself it all goes a bit crazy and app.js deletes the entire body and never works.

The question is. Is there a way to delay the start of Sencha and the app.js being loaded? Or is there a way to do what I want to do above without fundamentally changing my entire app.

Any recommendations welcome.

Rick
  • 186
  • 2
  • 7
  • Can you share the code where you are making this async call? Is it in the app.js launch function by any chance? – mindparse Feb 15 '15 at 18:59
  • I have moved it into a JS file that runs before Sencha's micro loader in the index page. However all the getPreferredLanguage call is async it immediately starts to instantiate the Sencha application. I want the micro loader to only run after the onComplete of the getPreferredLanguage function has been called. – Rick Feb 15 '15 at 19:07
  • I've ran into something similar before, although it seems hackerish could you use a callback on the async request `getPreferredLanguage` to instantiate the app? [Something similar to this](https://fiddle.sencha.com/#fiddle/ia0). – weeksdev Feb 15 '15 at 19:44
  • That's what I wanted to do, and have tried. But every time I delay the Sencha app starting it goes crazy and deletes the whole body, the code is no different. But apparently Sencha really likes to be started in the head and straight away. – Rick Feb 15 '15 at 19:55

0 Answers0