Closed SaidTayebi closed 9 years ago
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 :/
1.3. The thing is, I have a "_common" in each file but stil got the error.
Do you have a gist with how you try to change the lang, also a small exemple to have this error.
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"
});
Ok I've seen it once. It's a bug coming from this commit https://github.com/dhoko/angular-ngBabelfish/commit/0f486aae084fb555acc0134e4d04d23fd2f8cd77 (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.
It should be ok now. v1.7.2 is available with the patch.
Works fine ! Thanks. BTW: Great work, very helpful library
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