Comments (16)
Hey @danielbsig !
So, the problem here is, that you're returning an array of resolved values through $q.all
(as you can see here: http://docs.angularjs.org/api/ng.$q#all). angular-translate doesn't handle a sets of promised values, as you can see here: https://github.com/PascalPrecht/angular-translate/blob/master/src/translate.js#L512-L526.
You could either define loaders for your different sub apps, or we have to teach angular-translate to handle sets of promised values :)
I think the latter would be a cool thing!
from angular-translate.
But it won't work how its currently implemented, since the resolved data, which is actually a translation table, has to map to a corresponding language key. Now, when uses()
triggers $loaderFactory
with a language key, and we'll getting back an array of translation table then, how should angular-translate know, which table corresponds to which key?
We only have the key which should be used in this case.
from angular-translate.
Ah damn, just looked at your code again. Your loader tries to load translation tables for just one key, for sure. Okay, so I think we can implement this.
Do you want to make a PR, or should I take care of it?
from angular-translate.
Okay, that was easy. Landed in canary right here: 0e5d6d9 will make a minor release soonish!
from angular-translate.
Landed in master 0.9.3
! :)
Now do $ bower cache-clean
and afterwards $ bower install angular-translate
:)
from angular-translate.
Lemme know if everything works as expected!
from angular-translate.
Yes, this is the solution I came up with as well (although I have an additional check if this is an array of promises, as I see it the JSON file could theoretically contain an array of language definitions, but this is unlikely...)
And this works... kind of, but not completely. I'm not sure why, there seems to be a timing issue here, since some elements do get translated, but others won't. I'm not sure if a $scope.apply() would be needed, I have to investigate this a bit further.
I'm also having problems with loading json files which contain sub-definitions, i.e. something like this:
{
'myFirstSubApp': {
'FOO': 'bar',
'SMURF': 'barf'
}
}
but this is another problem and shouldn't be a part of this issue :-)
from angular-translate.
@danielbsig okay, so how about setting up a plunker with your exact problem, so I can take a look at it. Would love to help you out!
from angular-translate.
Yep, that was next on my TODO list :-)
from angular-translate.
Great, just post the plunk here when you're done
from angular-translate.
Check this out:
I may have made some errors, but at least this behaves in a similar way.
from angular-translate.
Okay, taking a look at it now
from angular-translate.
Here's the fix: http://plnkr.co/edit/1gtXwr?p=preview
$q.all()
excepts and array of promises, not an array of deferreds :)
from angular-translate.
It's line 20 in app.js by the way :)
from angular-translate.
Ah thank you very much :-)
I'm still a bit rusty when it comes to the concept of a promise. But this is then fully resolved!
from angular-translate.
Awesome!
from angular-translate.
Related Issues (20)
- Use templated string as key HOT 1
- bower repo doesn't have latest release tag HOT 3
- De-cloaking broken in 2.18.2 HOT 4
- Default interpolationParams allows access to function constructor HOT 1
- translate dynamic content loaded with ajax HOT 1
- How to use UI router with angular translate? HOT 1
- [email protected] support HOT 5
- translate-sanitize-strategy HOT 4
- “SameSite” attribute warning HOT 1
- Not changing languages on ng-click
- Cookie “NG_TRANSLATE_LANG_KEY” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute. HOT 9
- Two Languages at same time HOT 1
- IOS cordova When i upgrade the AngularJs to 1.8.2 the words will be missed which was been translated. HOT 1
- Using AngularJS Filters with Pluralization via MessageFormat HOT 1
- $translatePartialLoader.doesnot allow ë à á characters HOT 4
- $translate.instant with angular expression HOT 1
- Unexpected behavior registering translations with .translations() and using an async loader with .forceAsyncReload(true) HOT 3
- Partial loading can fail silently without any hints HOT 1
- $translateStaticFilesLoader should behave gracefully when one of translations cannot be loaded HOT 1
- Team awareness required: Future project state HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-translate.