Closed Nowi5 closed 6 years ago
Update on LinkRepository
Add
protected $translationRepo;
public function __construct()
{
$this->translationRepo = app(TranslationRepository::class);
}
Change update
public function update($links, $input)
{
$input['external'] = isset($input['external']) ? $input['external'] : 0;
if (!empty($input['lang']) && $input['lang'] !== config('quarx.default-language', 'en')) {
return $this->translationRepo->createOrUpdate($links->id, 'Yab\Quarx\Models\Link', $input['lang'], $input);
} else {
unset($input['lang']);
return $links->update($input);
}
}
Add use Translatable; to Link Model
Change edit.blade.php
@if (! is_null(request('lang')) && request('lang') !== config('quarx.default-language', 'en'))
{!! FormMaker::fromObject($links->translationData(request('lang')), Config::get('quarx.forms.link')) !!}
@else
{!! FormMaker::fromObject($links, Config::get('quarx.forms.link')) !!}
@endif
Change main-menu.blade.php to something like that:
@if ((config('app.locale') !== config('quarx.default-language')))
@if ($link->translation(config('app.locale')) !== null)
@if ($link->external)
<li><a href="{{ url($link->translation(config('app.locale'))->data->external_url) }}">{{ $link->translation(config('app.locale'))->data->name }}</a></li>
@else
<li><a href="{{ url(Config::get('app.locale_prefix').'/'.\Yab\Quarx\Models\Page::find($link->page_id)->url) }}">{{ $link->translation(config('app.locale'))->data->name }}
</a></li>
@endif
@endif
@else
@if ($link->external)
<li><a href="{{ url($link->external_url) }}">{{ $link->name }}</a></li>
@else
<li><a href="{{ url(Config::get('app.locale_prefix').'/'.\Yab\Quarx\Models\Page::find($link->page_id)->url) }}">{{ $link->name }}
</a></li>
@endif
@endif
Based on general feedback I'm doing a full review and refactoring of translations and will be including menus in this process. #132
Hi all,
with Quarx I can translate all my pages and blog entries, which can have different links. But I can't translate menu or more specific the link name. Creating multiple Menus per Language does not make sense in my context. How can I have one menu with multiple translations per link?
Thank you.