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

Change generic _ name to text in views #41079

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Jun 28, 2023

Summary of Changes

According to the discussion in #41063 the _ function in the view class should be renamed to text to be more meaningful.

@wilsonge
Copy link
Contributor

So it's worth noting that _ is a native PHP Function - which I assume is why it was picked in the first place which is an alias for gettext https://www.php.net/gettext (not that we're using this but I assume that people were assumed to be familiar with it)

So did some digging around just to compare what people do. Several bigger projects effectively build their own global function which is designed to mimic the PHP API:

Laravel (__ https://laravel.com/docs/10.x/localization)
Wordpress (__ https://developer.wordpress.org/apis/internationalization/internationalization-functions/)

Things that are more like this proposal:
Drupal https://www.drupal.org/docs/7/api/localization-api/localization-api-overview (a t function)
Symfony https://symfony.com/doc/6.2/the-fast-track/en/28-intl.html (via twig has a trans function)

@HLeithner
Copy link
Member

I also thought about t() but it also doesn't say anything what it is doing on, trans is longer and then text and is not a complete word ;-) beside that, as brain mentioned and I also mentioned internally could look like "more work the developer that doesn't like to translate text" (just an opinion).

__ is only 2 characters shorter then text and actually has no meaning, especially for people which are not developer and only want to modify a template override.

So I'm in favor for text().

@laoneo
Copy link
Member Author

laoneo commented Jun 28, 2023

Thanks @wilsonge for the comparison. I would also stay on text as it is more meaningful.

@laoneo laoneo mentioned this pull request Jun 28, 2023
4 tasks
@HLeithner HLeithner merged commit 713fa82 into joomla:4.4-dev Jun 28, 2023
3 checks passed
@laoneo laoneo deleted the view/text branch June 28, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants