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

Is it possible to translate BREAD BROWSE columns? #5829

Open
enkhtulga opened this issue Jan 5, 2024 · 5 comments
Open

Is it possible to translate BREAD BROWSE columns? #5829

enkhtulga opened this issue Jan 5, 2024 · 5 comments
Labels

Comments

@enkhtulga
Copy link

Laravel version

9

PHP version

7.4

Voyager version

1.4.3

Description of problem

Is it possible to translate BREAD BROWSE columns when user changed his/her language in profile? So how to do it?
For example:

English -> Mongolia:

Order - Дараалал
Name - Нэр
Slug - Слаг

Screen Shot 2024-01-05 at 14 51 41

Proposed solution

Is it possible to translate BREAD BROWSE columns when user changed his/her language in profile? So how to do it?

Alternatives considered

Is it possible to translate BREAD BROWSE columns when user changed his/her language in profile? So how to do it?

Additional context

Is it possible to translate BREAD BROWSE columns when user changed his/her language in profile? So how to do it?

@Emerica
Copy link
Contributor

Emerica commented Jan 5, 2024

I think so, appears to look that way anyways.

https://voyager-docs.devdojo.com/core-concepts/multilanguage

You can also add bread to the translations table pretty easily by using "TCG\Voyager\Models\Translation" as a model, or build your own that extends it. If you search the repo here for getTranslatedAttribute

The browse blade takes a datatype, which has datarows.
Datatype and DataRows have the translator trait applied.
Type uses "display_name_singular, display_name_plural" and Row uses "display_name"

{{ $row->getTranslatedAttribute('display_name') }}

So you should just be able to make translation entries for your table.
The tricky part is that Voyager hides the DataTypes and Rows Tables.
You can use tinker or debug another way.

For example
Run php artisan tinker and then type

TCG\Voyager\Models\DataType::where('name','categories')->first()->rows->pluck('display_name','id')

This will give you a list of data rows with their display_name and corresponding id. You can use 'name' if you don't want the case confusion.

Now go into the Bread for translations that you just made and add a new entry.
Set the fields as follows:
Table Name : data_rows
Column Name: display_name
Foreign Key: [ID VALUE FROM QUEURY FOR COLUMN]
Locale: [WANTED LOCALE]
Value: [TRANSLATED VALUE]

Now when your user changes their locale, that data_row will get translated.

@Emerica
Copy link
Contributor

Emerica commented Jan 5, 2024

image
image
Notice the first column is now translated.

@enkhtulga
Copy link
Author

@Emerica Thank you so much. 🙇🏻‍♂️🙇🏻‍♂️🙇🏻‍♂️

@enkhtulga
Copy link
Author

@Emerica how to create PR for new unsupported locale?
I have already translated. When i try to push then it says:

git push --set-upstream origin adding-a-new-unsupported-locale-mongolia-mn
remote: Permission to thedevdojo/voyager.git denied to enkhtulga-gantsagaan.
fatal: unable to access 'https://github.com/thedevdojo/voyager.git/': The requested URL returned error: 403

@Emerica
Copy link
Contributor

Emerica commented Jan 17, 2024

I think you have to commit to your own fork vs master and then submit the pull in github from your fork.
Keep in mind, the maintainers don't seem to spend as much time going over those it seems, so it might be some time for it to be picked up. Don't let it discourage you if it sits...

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

No branches or pull requests

2 participants