Granite.i18n undefined - editable templates | Community
Skip to main content
sreenu539
Level 7
Aug 30, 2018 12:34 AM UTC
Solved

Granite.i18n undefined - editable templates

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 30, 2018 8:30 PM UTC

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

Thanks

Arun

Arun Patidar

5 replies

sreenu539
sreenu539Author
Level 7
Aug 30, 2018 11:57 PM UTC

Correct. Added granite.utils as category dependency.

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 30, 2018 8:30 PM UTC

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

Thanks

Arun

Translate
Arun Patidar
sreenu539
sreenu539Author
Level 7
Aug 30, 2018 6:30 PM UTC

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

Translate
sreenu539
sreenu539Author
Level 7
Aug 30, 2018 6:29 PM UTC

Granite is defined but not i18n.

Translate
arunpatidar
New Participant
Aug 30, 2018 7:27 AM UTC

Hi,

Try below:

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

    Granite.I18n.setLocale('en_US');

}

Translate
Arun Patidar