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

[4.x] Replace __() with Statamic\trans() #9525

Merged

Conversation

duncanmcclean
Copy link
Member

This pull request replaces the __() helper with the Statamic\trans() helper, which should prevent issues when language files exist with the same name, eg: forms or email.

Fixes #7672.

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very thorough, thank you.

But man is it ugly. 😆

Can we just add use statements to the blade files so we can keep __ everywhere?

Like this:

@php use function Statamic\trans as __; @endphp

@duncanmcclean
Copy link
Member Author

Agreed, it's certainly not pretty.

Although, I've just tried your suggestion in importing the Statamic\trans helper as __ but it doesn't look like that'll work. I'm still getting the original htmlspecialchars error 🤔

I haven't committed those changes, since they didn't help. However, if you want to give it a test, here are the changes as a .patch file: 0001-Add-use-statements-to-views-instead.patch

@jasonvarga
Copy link
Member

That patch (applied onto 4.x) seems to work fine. Which URL is still causing the error?

@duncanmcclean
Copy link
Member Author

Oh, maybe I was doing something wrong then. I was going to the form show page.

@jasonvarga
Copy link
Member

I was going to the form show page.

Yep, I still get there error. Turns out you need to add the import to breadcrumb.blade.php.

…he-same-name

# Conflicts:
#	resources/views/utilities/partials/email-l6.blade.php
#	resources/views/utilities/partials/email-l7.blade.php
@duncanmcclean
Copy link
Member Author

duncanmcclean commented Feb 20, 2024

Ah, that fixes it! Pushed it up.

@jasonvarga jasonvarga merged commit f7a247b into 4.x Feb 20, 2024
35 checks passed
@jasonvarga jasonvarga deleted the fix/translations-when-lang-file-exists-with-the-same-name branch February 20, 2024 17:58
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

Successfully merging this pull request may close these issues.

Lang file causing an error
2 participants