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

Consider using decorator instead prefix and suffix #161

Open
vlytvyne opened this issue Oct 4, 2021 · 0 comments
Open

Consider using decorator instead prefix and suffix #161

vlytvyne opened this issue Oct 4, 2021 · 0 comments

Comments

@vlytvyne
Copy link

vlytvyne commented Oct 4, 2021

Interface LookupMessages declares following methods to append "ago" to the formatted time:

/// Example: `prefixAgo()` 1 min `suffixAgo()`
String prefixAgo();

/// Example: `prefixFromNow()` 1 min `suffixFromNow()`
String prefixFromNow();

/// Example: `prefixAgo()` 1 min `suffixAgo()`
String suffixAgo();

/// Example: `prefixFromNow()` 1 min `suffixFromNow()`
String suffixFromNow();

which should be overridden by the client in order to apply custom locale, which is rather inconvenient if you get those locales dynamically. I think that something like decorateWithAgo(String formatted time) might be more flexible as a client doesn't have to worry about providing 2 types of prefixes and 2 types of sufixes (which may or may not be present in some languages) but instead just provide simple realization of decorateWithAgo method.

Please, compare:

@override
String prefixAgo() => 'hace';

@override
String prefixFromNow() => 'dentro de';

@override
String suffixAgo() => '';

@override
String suffixFromNow() => '';

and

@override
String wrapWithAgo(String formattedTime) => 'hace $formattedTime';

Note that the vast majority of people will use either "ago" OR "from now" across all of the app. Also, not all languages really have "from now" analog, which makes prefixFromNow, suffixFromNow not so relevant and rather confusing.

What are your thoughts?

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

No branches or pull requests

1 participant