Z3d0X / filament-fabricator

Block-Based Page Builder Skeleton for your Filament Apps
https://filamentphp.com/plugins/fabricator
MIT License
252 stars 48 forks source link

Localization Support #75

Closed MaartenJC closed 5 months ago

MaartenJC commented 1 year ago

I use Fabricator with Spatie Translatable. So slugs are stored like: {"nl":"test-nl","de":"test-de"}

When the Dutch locale is set, the pageUrls are like this: $pageUrls[1] = "/test-nl"

This is Cached with the key: filament-fabricator::page-urls

When the German page is requested, the Dutch $pageUrls are returned so no page is found.

Z3d0X commented 1 year ago

I don't think this package is compatible with spatie translatable

MaartenJC commented 12 months ago

It actually works great except for this problem. So would it be an option to modify te code from: $pageUrls = FilamentFabricator::getPageUrls(); to: $pageUrls = FilamentFabricator::getPageUrls($locale);

Z3d0X commented 12 months ago

Ok I will look in to this for future updates

Nestoran commented 11 months ago

Has this been implemented already? Any news on this?

Voltra commented 7 months ago

Hi there! I have been able to use Spatie Translatable with Fabricator.

I've done this by simply overriding FilamentFabricatorManager#setPageUrl as well as the routing and the route parameter binding. Just to ensure everything works smoothly, I also added a locale detector middleware.

Voltra commented 7 months ago

I've made a gist for that: https://gist.github.com/Voltra/191666f4af51e42528e54bfc682661e9

Z3d0X commented 7 months ago

@Voltra I'd be open to a PR on this as a opt-in feature. (eg: needs to be enabled in the config to use it)

Z3d0X commented 5 months ago

As described in this comment https://github.com/Z3d0X/filament-fabricator/pull/119#issuecomment-1890588386 localization is better off as a project side configuration