Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Granite.i18n undefined - editable templates

Avatar

Level 7

I have created a page with empty editable template. I have structure page inside my application and following code throwing a js error : "Cannot read property setLocale of undefined"

if (typeof Granite !== "undefined") {
    Granite.I18n.setLocale('en_US');
}

Any ideas ?

Thanks,

Sri

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

Granite.I18n is defined in http://localhost:4502/etc.clientlibs/clientlibs/granite/utils.js

Can you check if this file is loaded for not?

in Author I didn't added any dependancy explicitly because this file is loaded due to dependency of cq.authoring.dialog and can see I18n in console

You can explicitly load this. category for utils.js is granite.utils

Screen Shot 2018-08-30 at 10.21.24 PM.png

Thanks

Arun



Arun Patidar

View solution in original post

5 Replies

Avatar

Community Advisor

Hi,

Try below:

if (Granite !== 'undefined' || Granite !== null) {

    Granite.I18n.setLocale('en_US');

}



Arun Patidar

Avatar

Level 7

Granite is defined but not i18n.

Avatar

Level 7

I am more interested in knowing if I need to any client libs as dependency for application client lib category.

Avatar

Correct answer by
Community Advisor

Hi,

Granite.I18n is defined in http://localhost:4502/etc.clientlibs/clientlibs/granite/utils.js

Can you check if this file is loaded for not?

in Author I didn't added any dependancy explicitly because this file is loaded due to dependency of cq.authoring.dialog and can see I18n in console

You can explicitly load this. category for utils.js is granite.utils

Screen Shot 2018-08-30 at 10.21.24 PM.png

Thanks

Arun



Arun Patidar

Avatar

Level 7

Correct. Added granite.utils as category dependency.