[ 6 posts ]

Francesco Pongiluppi

YUI Contributor

  • Username: willywongi
  • Joined: Fri May 15, 2009 4:28 am
  • Posts: 41
  • GitHub: willywongi
  • Gists: willywongi
  • Offline
  • Profile

Intl and custom modules

Post Posted: Thu May 03, 2012 4:34 am
+0-
This is my situation:
- a custom YUI_config in the page that defines a group (among other things) that will be served through Apache (no combo handler), which uses the configFn to adjust the path that will be used to load the .js file (mygroup-mymodule-1.4 turns into mymodule/1.4/mymodule-min.js).
- a module like this:
Code:
YUI.add('mygroup-mymodule-1.4', function(Y) {
    var strings = Y.Intl.get('mygroup-mymodule-1.4');
    Y.myTranslatedFunction = function() {
        return strings.test
    }
}, '1.4.0', {"requires": ["collection", "node", "intl"], "lang": ['it', 'en']});

- a page with inlined translations about a custom module:
Code:
YUI.add("lang/mygroup-mymodule-1.4", function(Y) {
   Y.Intl.add("mygroup-mymodule-1.4", '', {
         'test': 'stringa di test'
      });
}, '1.4', {'requires': ['intl']});
YUI.add("lang/mygroup-mymodule-1.4_en", function(Y) {
   Y.Intl.add("mygroup-mymodule-1.4_en", '', {
         'test': 'test string'
      });
}, '1.4', {'requires': ['intl']});

- lastly, a YUI().use:
Code:
YUI().use("mygroup-mymodule-1.4", function(Y) {
    Y.log('Sandbox 0');
    Y.log(Y.myTranslatedFunction());
});
YUI().use("mygroup-mymodule-1.4", function(Y) {
    Y.log('Sandbox 1');
    Y.log(Y.myTranslatedFunction());
});
YUI().use("node", "event", "mygroup-mymodule-1.4", function(Y) {
   Y.one("#test").on('click', function(e) {
      alert(Y.myTranslatedFunction());
   });
   
});

Result is:
Code:
Sandbox 0
undefined
Sandbox 1
undefined

Clicking on the #test element produces an alert with "undefined". Oddly enough, when tested through the console, and only there, I get my translated text.
Code:
YUI().use("mygroup-mymodule-1.4", function(Y) { Y.log(Y.myTranslatedFunction()); });

Putting a log in the definition of the language modules reveals that they are pulled in (executed) only in this last case. I really can't see what's wrong here.

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile
Tags:

Re: Intl and custom modules

Post Posted: Thu May 03, 2012 5:32 am
+0-
What version of YUI are you using for this? I "think" I fixed this issue in 3.5.0..

Francesco Pongiluppi

YUI Contributor

  • Username: willywongi
  • Joined: Fri May 15, 2009 4:28 am
  • Posts: 41
  • GitHub: willywongi
  • Gists: willywongi
  • Offline
  • Profile
Tags:

Re: Intl and custom modules

Post Posted: Thu May 03, 2012 8:28 am
+0-
Sorry, I forgot this key piece of info!
I'm facing this *after* upgrading from 3.4.1 to 3.5.0; I thought this could be related to #2531451 myself too, but I simply can't go through all the Loader code!

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile
Tags:

Re: Intl and custom modules

Post Posted: Thu May 03, 2012 8:56 am
+0-
Can you put together a repro case that I case test against so I can debug it? Open a ticket and attach the test case so I can get to the root of the issue.

Francesco Pongiluppi

YUI Contributor

  • Username: willywongi
  • Joined: Fri May 15, 2009 4:28 am
  • Posts: 41
  • GitHub: willywongi
  • Gists: willywongi
  • Offline
  • Profile
Tags:

Re: Intl and custom modules

Post Posted: Fri May 04, 2012 6:27 am
+0-
I opened this ticket and put the test case.
#2532268
There will be chances that this fix will eventually land in 3.5.1? We need to plan ahead our transition to 3.5.x. Thank you!

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile

Re: Intl and custom modules

Post Posted: Fri May 04, 2012 7:14 am
+0-
3.5.1's code freeze is already over. But if I can get it in today it will make it into 3.6.0PR1
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum