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

Move name and description into a getter function #24

Open
alexstandiford opened this issue May 26, 2020 · 3 comments
Open

Move name and description into a getter function #24

alexstandiford opened this issue May 26, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@alexstandiford
Copy link
Collaborator

It would probably be best if name and description were put in a getter method. Most plugins want to translate these, and we shouldn't force all implementations to set these up when they're not used in most-cases.

@alexstandiford
Copy link
Collaborator Author

alexstandiford commented May 26, 2020

It would be best to use the __get magic method in classes that use translation strings, instead of setting these in the constructor.

This would prevent a refactor across sites, and allow us to benefit from PHP's own methods to do this, anyway.

EDIT

It won't be this simple because description and name are public, and we don't have the context for the translation strings.

For now, unfortunately, we probably have to just leave it as it is and think deeper on how this can be handled better.

@alexstandiford
Copy link
Collaborator Author

The key motivation for putting these in a getter method is to make them translate-able without running the constructor. Related to #36.

Perhaps the string is untranslated if you access the value directly, and there's some way baked into the trait to handle one-time translating of these items if a specific getter method is called?

@alexstandiford
Copy link
Collaborator Author

underpin::__ is now a method, and these items can be translated programmatically without a constructor, so adding this to a __get method should work nicely.

@alexstandiford alexstandiford added the good first issue Good for newcomers label Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant