Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the tokens #52

Closed
harikt opened this issue Aug 2, 2014 · 13 comments
Closed

How to get the tokens #52

harikt opened this issue Aug 2, 2014 · 13 comments
Labels

Comments

@harikt
Copy link
Member

harikt commented Aug 2, 2014

When working with Aura.Intl how could we get the tokens that need to be passed .

Eg :

"FILTER_RULE_FAILURE_IS_NOT_BETWEEN" => "Please do not use a value between {min} and {max}.",

The min and max , may be something like getTokens() on the RuleCollection::addMessageFromRule will help ?

array(
    'min' => $min,
    'max' => $max,
);

/ cc @cordoval

@harikt harikt added the v2 label Aug 2, 2014
@harikt
Copy link
Member Author

harikt commented Aug 13, 2014

@cordoval @pmjones any thoughts on this?

What I was thinking was getParams or getTokens . Paul was having an idea of using the rule itself back in the filter.

Thoughts ?

@harikt
Copy link
Member Author

harikt commented Dec 19, 2014

Closing for a different approach is being used.

@harikt harikt closed this as completed Dec 19, 2014
@harikt harikt reopened this Dec 28, 2014
@harikt
Copy link
Member Author

harikt commented Dec 28, 2014

Hi Paul,

I don't know whether I am throwing something before the complete implementation. But I would like to ask a question .

I feel when we are using something like FILTER_SOMETHING it is easy for people to make use of translate $this->translate('FILTER_SOMETHING') . In some cases we may need more stuffs like the minimum length, maximum, between etc. In that case it would be good to also get these token values so it can be passed as $this->translate('FILTER_SOMETHING', $params) .

If it is just string like field should have validated as strlenMin(6) things may be hard to translate I assume. Your thoughts ?

Apart from that the reorg branch seems nice.

Thank you

@pmjones
Copy link
Member

pmjones commented Dec 28, 2014

Fair question!

First, the "strlen(6)" thing is a default message only, and is intended to be overridden with a custom message. You provide a custom message by specifying the rule mode, e.g. ->asSoftRule("Please enter a valid email address.").

For translation, you could enter "FILTER_SOMETHING" as the message, and then pass it through a translator at output time, but it still doesn't get you the filter arguments, like 6 as in strlenMin(6).

To support translations with interpolated argument values, I can see where we would have to change the getMessages() return format so that it returns both the string message and the filter arguments. Let me think about that one a little bit.

@harikt
Copy link
Member Author

harikt commented Dec 28, 2014

@pmjones this was what I did earlier https://github.com/auraphp/Aura.Filter/pull/53/files . But as things are changed it need a bit different ways though .

@pmjones
Copy link
Member

pmjones commented Jul 3, 2015

I think we're getting closer to a final implementation here. Do you think this issue is still important, or is it something we can let go?

@harikt
Copy link
Member Author

harikt commented Jul 3, 2015

Hi @pmjones ,

I think this issue is a bit important when you want to deal with translation.

What I thought was keeping something like having a constant values and use some getTokens or something to get the tokens. The user can later use a translator like Aura.Intl or other ones which does the conversion.

@pmjones
Copy link
Member

pmjones commented Jul 3, 2015

@harikt I blame you: #84

@harikt
Copy link
Member Author

harikt commented Jul 4, 2015

Thank you @pmjones . Looks good 👍 .

@harikt
Copy link
Member Author

harikt commented Jul 4, 2015

By the way @pmjones in case if you have not forgotten https://groups.google.com/d/msg/auraphp/dVpSOV6RnM4/BZLPpYzMoDQJ before a beta release good to have common interface, so it can communicate with Aura.Input also ?

@pmjones
Copy link
Member

pmjones commented Jul 4, 2015

Closed by #84 .

@pmjones pmjones closed this as completed Jul 4, 2015
@pmjones
Copy link
Member

pmjones commented Jul 4, 2015

@harikt The rules for Aura 1.x packages are such that they cannot depend on external packages, which means even if there was an interface package, Aura.Input 1.x could not depend on it. At the worst, though, there could be a "bridge" interface between the two in yet another package.

@harikt
Copy link
Member Author

harikt commented Jul 5, 2015

@pmjones As Aura.Filter is v2, we can bring an interface to 2.0 . And later the 1.0 package can be bumped to 2.0 to use the same interface package. No other changes for Aura.Input .

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

No branches or pull requests

2 participants