-
Notifications
You must be signed in to change notification settings - Fork 1k
Translate attributes with translate directive #568
Comments
Indeed! @red-0ne wanna start implementing it? |
Of course. I just wanted to know if it is the way to go. |
@red-0ne I think the idea is great. I'm also pretty okay with <ANY translate-attr-{attr}=""></ANY> syntax.
That's all I have. Any other ideas? |
Pay attention to attributes that are manipulated by other directives? (already defined attributes) |
@red-0ne could you elaborate on that? |
how to deal with |
what about |
If the Attributes will be either observed or binded in the scope, any change to the attribute should be available like others. Just like translate and its translation id. |
@red-0ne if there are already attributes with a value, they would get over written. Since it doesn't make real sense to have both on an element. When you know there's an element with a I think the most cases would be covered with that approach. Maybe we should just go for it now and ignore a possible |
You are right, caring about other overrides is pointless |
@red-0ne oh no, please don't get me wrong. I just think we can deal with these issues once they occur. Because currently it's hard to say how to handle such cases. We have to play with directive priorities I think. However, if you have an idea to tackle it, don't hesitate and tell me :) I'm happy and open for great ideas. |
@PascalPrecht i am ok with you, It is wiser to deal with the issue once it arises. |
For other directives that could change the value, we can observe the attribute for changes but these directives should be angular-translate aware. |
Apparently there is no way to have a |
Could you elaborate on why we couldn't go the other way without hacking |
There is no way to register a directive that is called for a "wildcard/regex" attribute. The only way to have |
@red-0ne Ah getting your point now. So, we actually don't need to introduce a new directive. Attributes like So first it checks if the attribute exists at all: https://github.com/angular-translate/angular-translate/blob/master/src/directive/translate.js#L92 And then it goes ahead evaluates the values out of them: https://github.com/angular-translate/angular-translate/blob/master/src/directive/translate.js#L123-L134 So in the end, basically what you said. But I don't think we have to introduce So if we have something like I think that's the way to go. Thank you very much for you input already! |
Perfect. I'll make a pull request ASAP |
@red-0ne great! Looking forward to it! |
Pinging @red-0ne 😃 |
Maybe I am missing something, but I didn't see an update on this ticket. I haven't come up with a solution that I liked using a syntax of: I just created a quick plunkr using a object literal convention like:
http://plnkr.co/edit/1NfcEO?p=preview I can draft a PR if this is a direction you want to go. |
Add to the translate directive the ability to act on attributes. Using the translate-attr-ATTR as an attribute, ATTR will be translated. translate-default, translate-value and interpolation are possible. Closes angular-translate#568
Add to the translate directive the ability to act on attributes. Using the translate-attr-ATTR as an attribute, ATTR will be translated. translate-default, translate-value and interpolation are possible. Closes #568
Add to the translate directive the ability to act on attributes. Using the translate-attr-ATTR as an attribute, ATTR will be translated. translate-default, translate-value and interpolation are possible. Closes #568
`translationIds` cannot be stored in scope because will be interpolated recursivly Relates angular-translate#568
How do I translate an attribute only but not tag contents? See what I'm saying:
This replaces the inner content of |
Just curious, reading how attributes are added here...
|
Actually, the only way to translate elements attributes is through the translate filter. Is there a particular reason to not having a directive for that?
<any translate-attr-my-attr="'TRANSLATION_ID'"></any>
could be a great feature.The text was updated successfully, but these errors were encountered: