Granite.i18n undefined - editable templates | Community
Skip to main content
sreenu539
Level 7
August 30, 2018
Solved

Granite.i18n undefined - editable templates

  • August 30, 2018
  • 5 replies
  • 2457 views

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.
Best answer by arunpatidar

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

5 replies

arunpatidar
Community Advisor
Community Advisor
August 30, 2018

Hi,

Try below:

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

    Granite.I18n.setLocale('en_US');

}

Arun Patidar
sreenu539
sreenu539Author
Level 7
August 30, 2018

Granite is defined but not i18n.

sreenu539
sreenu539Author
Level 7
August 30, 2018

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

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
August 30, 2018

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
sreenu539
sreenu539Author
Level 7
August 30, 2018

Correct. Added granite.utils as category dependency.