Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

translate-attr not working #1577

Closed
nunof07 opened this issue Sep 6, 2016 · 18 comments
Closed

translate-attr not working #1577

nunof07 opened this issue Sep 6, 2016 · 18 comments
Labels
Milestone

Comments

@nunof07
Copy link

nunof07 commented Sep 6, 2016

Subject of the issue

Reading the documentation I would expect translate-attr to work, but I could only get it working using the deprecated way.

Using translate-attr="{ placeholder: 'placeholder' }" doesn't work.
Using translate translate-attr-placeholder="placeholder" works.

Your environment

  • version of angular-translate: 2.12.0
  • version of angular: 1.5.8

Steps to reproduce

Plunker: http://plnkr.co/edit/oIXnkRVHpO3xP4kDdsJ9?p=preview

@tspaeth
Copy link
Member

tspaeth commented Sep 6, 2016

Looks like the directive "translateAttr" is not included in the dist build result.

@tspaeth tspaeth added the bug label Sep 6, 2016
@tspaeth
Copy link
Member

tspaeth commented Sep 6, 2016

@odedniv The translate-attr.js file is having some issues on the jshint step as well. (as introduced by #1550 )

@odedniv
Copy link
Contributor

odedniv commented Sep 6, 2016

Running grunt test I don't see any error, not sure how else to trigger them.

Should the new file maybe be added to https://github.com/angular-translate/angular-translate/blob/master/Gruntfile.js ?

Is there some build process to run?

@tspaeth
Copy link
Member

tspaeth commented Sep 6, 2016

Yup, it must be added somewhere around line 60 in that file, then it will be added to the core js.
The fix will probably take some days as @knalli is afaik off for some days and I'm not 100% aware of the release process currently. 😞

@odedniv
Copy link
Contributor

odedniv commented Sep 6, 2016

In this case I won't be touching anything... Glad to see people need it 😄

@knalli
Copy link
Member

knalli commented Sep 6, 2016

Ah.. the grunt file have to be patched adding the new js file also. Sorry, overseen this.

PRs are welcome, then I can handle this next week.

@kopancek
Copy link
Contributor

Added a PR, feel free to review.

@knalli knalli added this to the 2.12.1 milestone Sep 15, 2016
@knalli
Copy link
Member

knalli commented Sep 15, 2016

Will be available in 2.12.1 shortly.

@knalli knalli closed this as completed Sep 15, 2016
@dbrgn
Copy link

dbrgn commented Sep 19, 2016

Doesn't seem to work for me though... Maybe I'm doing something wrong? Can someone confirm that it works now with the version installed through bower?

@knalli
Copy link
Member

knalli commented Sep 19, 2016

Here is a demo http://plnkr.co/edit/BjccjrhDqaweUHrkykx2?p=preview using the 2.12.1 tag, which is automatically the bower release of 2.12.1

@dbrgn
Copy link

dbrgn commented Sep 19, 2016

@knalli thanks. strange, then I'll have to debug some more :)

@a-change
Copy link

Hi,
Don't know if it's a bug or it isn't supposed to work this way or just my errors somewhere, but it seems that translate-attr="" doesn't work for directive attributes, like in this case with ui-select:
<ui-select-match translate-attr="{placeholder: 'PLACEHOLDER'}">{{$select.selected.value}}</ui-select-match> (angular-translate: 2.13.1, angular: 1.6.1)
Here's a plunkr: https://plnkr.co/edit/r5aBGLVXIqXoxWvJSWge?p=preview

In this case it seems it successfully adds the attribute to the wrapping <div> but not to the <input> element inside it. Filter works fine and adds the attribute both to the <div> and the <input>.

A similar thing is reported here: http://stackoverflow.com/questions/41035450/angular-translate-directives-attribute-without-the-filter

@odedniv
Copy link
Contributor

odedniv commented Jan 25, 2017

@a-change this looks like a separate bug (which is not really stackoverflow material in my opinion).

Looks like the way translate-attr adds the attributes doesn't compile the element in the way ng-attr-* does for example (you can add new directives with ng-attr-*).

In my short search I couldn't find where ng-attr-* is implemented, though I'm afraid it's not a normal directive. If you can find how they do it and add a pull request that would probably be best, otherwise I encourage you to open a separate issue for this.

PS. what you wrote about ui-select might actually be a priority issue (or more than that if translate-attr is triggered on the next digest with a watcher), which is another different issue that might even be harder to solve.

@jamesbrobb
Copy link

Did this issue ever get resolved? I'm still experiencing it in version 2.15.1

@odedniv
Copy link
Contributor

odedniv commented Jun 20, 2017

@jamesbrobb which issue? Multiple things are discussed here. You should submit a new issue with your specific problem (this issue has been closed).

@jamesbrobb
Copy link

jamesbrobb commented Jun 20, 2017

@odedniv sorry, should have been more specific. I'm referring to the previous point raised by @a-change.

Using translate-attr to set a bound attribute does not appear to work.

@odedniv
Copy link
Contributor

odedniv commented Jun 23, 2017

@jamesbrobb I told @a-change as well - this is not related to the original bug opened by @nunof07, why not open a separate issue that can be discussed with a proper title?

@jamesbrobb
Copy link

jamesbrobb commented Jun 23, 2017 via email

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

No branches or pull requests

8 participants