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

Adding a static function for current locale to the tag #368

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

leonidlezner
Copy link
Contributor

The current locale is not get by app()->getLocale() but by a static function. With this change it is possible to implement custom logic of getting the locale inside of custom Tag. It can also be used to set the locale to a fixed value to "deactivate" the translation functionality.

@freekmurze
Copy link
Member

Thank you for this. Could you give an example of a situation where this functionality is needed?

@leonidlezner
Copy link
Contributor Author

I've added the tag functionality to the edit page of groups, which can be created by users. They can enter the tags, but they are saved with the current locale (can be set to German or English for each user). So when German users save the tags, English user don't see them. And vice versa. Those tags should contain the same information for all UI languages. By setting the return value of getLocale() to 'en' I can force the tag information to be saved for the same locale (now they are kind of language independent).

Bildschirmfoto 2021-11-15 um 22 51 22

@freekmurze
Copy link
Member

This looks good. Could you also update the docs explaining this functionality with a good, clear example?

@leonidlezner
Copy link
Contributor Author

I've added the example, hope it's clear enough :)

@freekmurze
Copy link
Member

I'll polish it a bit myself, thank you for this!

@freekmurze freekmurze merged commit 3ec6151 into spatie:main Nov 17, 2021
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.

None yet

4 participants