Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property '_common' of undefined #44

Closed
SaidTayebi opened this issue Feb 22, 2015 · 7 comments
Closed

Cannot read property '_common' of undefined #44

SaidTayebi opened this issue Feb 22, 2015 · 7 comments
Labels

Comments

@SaidTayebi
Copy link

In lazy mode I have this error when I switch the language. It doesn't break my app though.
I have a file for each language: fr-FR.json, nl-NL.json, en-EN.json

TypeError: Cannot read property '_common' of undefined
at Object.setTranslation as updateState
at bundle.js:583
at Scope.$get.Scope.$broadcast (angular.js:14720)
at x.transitionTo.x.transition.I.then.x.transition.x.transition (angular-ui-router.min.js:7)
at processQueue (angular.js:13189)
at angular.js:13205
at Scope.$get.Scope.$eval (angular.js:14401)
at Scope.$get.Scope.$digest (angular.js:14217)
at Scope.$get.Scope.$apply (angular.js:14506)
at dependencyResolverFor.js:13

@dhoko
Copy link
Owner

dhoko commented Feb 22, 2015

What is your version of Angular ?
How do you try to change the lang ?

I tried to remove _common from my demo for lazyMode, but there are no errors :/

@dhoko dhoko added the bug label Feb 22, 2015
@SaidTayebi
Copy link
Author

1.3.
The thing is, I have a "_common" in each file but stil got the error.

@dhoko
Copy link
Owner

dhoko commented Feb 22, 2015

Do you have a gist with how you try to change the lang, also a small exemple to have this error.

@SaidTayebi
Copy link
Author

I change the lang with data-i18n-load

each lang in languages
   - var country = (lang == 'fr') ? 'France' : (lang == 'nl') ? 'Netherlands' : (lang == 'en') ? 'United-Kingdom' : 'Belgium'
   - var langCountry = (lang == 'fr') ? 'FR' : (lang == 'nl') ? 'NL' : (lang == 'en') ? 'EN' : 'EN'
      li(class=(currentLanguage == lang) ? 'active' : '')
        a(href="", id="site-#{lang}" data-i18n-load="#{lang}-#{langCountry}")
            img(src="#{MEDIA_URL}images/global/flags/#{country}.png").flag-icon

And my config is:

babelfishProvider.init({
    namespace: 'i18n',
    state: 'dashboard',
    lang: $cookies["sy-locales"] + "-" + $cookies["sy-locales"].toUpperCase(), 
});

babelfishProvider
   .lang({
              lang: "fr-FR",
              url: "/i18n/fr-FR.json"
          })
          .lang({
              lang: "en-EN",
              url: "/i18n/en-EN.json"
          })
          .lang({
              lang: "nl-NL",
              url: "/i18n/nl-NL.json"
          });

@dhoko
Copy link
Owner

dhoko commented Feb 22, 2015

Ok I've seen it once. It's a bug coming from this commit 0f486aa (else if (config.lazy))

I don't know why we do not have this error everytime, and it should not be able to enter the condition. A patch is coming.

dhoko pushed a commit that referenced this issue Feb 22, 2015
@dhoko dhoko closed this as completed in d2d7ea6 Feb 22, 2015
dhoko added a commit that referenced this issue Feb 22, 2015
@dhoko
Copy link
Owner

dhoko commented Feb 22, 2015

It should be ok now. v1.7.2 is available with the patch.

@SaidTayebi
Copy link
Author

Works fine ! Thanks.
BTW: Great work, very helpful library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants