GithubHelp home page GithubHelp logo

Comments (16)

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

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.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

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.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

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.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

Okay, that was easy. Landed in canary right here: 0e5d6d9 will make a minor release soonish!

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

Landed in master 0.9.3 ! :)

Now do $ bower cache-clean and afterwards $ bower install angular-translate :)

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

Lemme know if everything works as expected!

from angular-translate.

danielbsig avatar danielbsig commented on May 22, 2024

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.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

@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.

danielbsig avatar danielbsig commented on May 22, 2024

Yep, that was next on my TODO list :-)

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

Great, just post the plunk here when you're done

from angular-translate.

danielbsig avatar danielbsig commented on May 22, 2024

Check this out:

http://plnkr.co/edit/Hx8eXN

I may have made some errors, but at least this behaves in a similar way.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

Okay, taking a look at it now

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

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.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

It's line 20 in app.js by the way :)

from angular-translate.

danielbsig avatar danielbsig commented on May 22, 2024

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.

0x-r4bbit avatar 0x-r4bbit commented on May 22, 2024

Awesome!

from angular-translate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.