Is it possible to translate BREAD BROWSE columns?
enkhtulga opened this issue · 5 comments
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 - Слаг
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?
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"
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 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
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...