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

Language-specific relationship names #2331

Closed
fisharebest opened this issue Mar 14, 2019 · 5 comments
Closed

Language-specific relationship names #2331

fisharebest opened this issue Mar 14, 2019 · 5 comments
Labels
enhancement feature request

Comments

@fisharebest
Copy link
Owner

fisharebest commented Mar 14, 2019

Now that we have modules for langauges, we have somewhere to store logic for language-specific relationship names. e.g.

  • cousins
  • great xN grandparents
  • Spanish consuegro / consuegra (child's spouse's parent)
  • etc.

Each language can define its own rules/translations.
Anything that is undefined will get a translation of the English relationship name.

@DaPoHou
Copy link
Contributor

DaPoHou commented Mar 14, 2019

That's great!Thank you very much.
I hope to give more examples and explanations.

@ric2016
Copy link
Contributor

ric2016 commented Apr 19, 2021

Should this be marked as solved? Other issues for specific languages reference this issue. These languages are not solved yet.

@ric2016
Copy link
Contributor

ric2016 commented Apr 19, 2021

Also, I really would prefer a more generic access point, e.g. in ModuleLanguageInterface

public function getRelationshipName(RelationshipPath $path): string;

so that specific languages/ custom modules get their chance to implement their logic differently, rather than having to provide an array of relationships. In your solution, how can specific languages define specific algorithms for splitting complex relationship paths?

@fisharebest
Copy link
Owner Author

fisharebest commented Apr 20, 2021

In your solution, how can specific languages define specific algorithms for splitting complex relationship paths?

I guess you could extend RelationshipService and replace nameFromPath().

if ($language has special logic) {
  return special_logic(...);
} else {
  return parent::nameFromPath(...);
}

But when I get feedback from more languages, then I expect the logic will change.

@ric2016
Copy link
Contributor

ric2016 commented Apr 20, 2021

Is there any chance that you'll consider generalizing the interface, as suggested?

I think this has advantages as it decouples the logic from the interface. After all, what is the abstract goal here? In my opinion, it is to get a translated relationship path name from a specific language.

So using a method that just returns this string seems more flexible, and more in line with similar methods from LocaleInterface, such as 'percent($number)' and 'number($number)'.

The current implementation can of course still be used to support modules in implementing this, i.e. they could use the RelationshipService to provide the result, but it would be easier to extend this with special logic, without having to change the interface later.

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

No branches or pull requests

3 participants