Skip to content

Commit

Permalink
Merge pull request #499 from Malcom1986/master
Browse files Browse the repository at this point in the history
Close #488  Fix breadcrums localization
  • Loading branch information
fey committed Aug 19, 2020
2 parents b80968f + 613ac2c commit ebaec2a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions resources/lang/en/breadcrumb.php
@@ -0,0 +1,6 @@
<?php

return [
'contents' => 'Contents',
'exercise' => 'Exercise',
];
6 changes: 6 additions & 0 deletions resources/lang/ru/breadcrumb.php
@@ -0,0 +1,6 @@
<?php

return [
'contents' => 'Оглавление',
'exercise' => 'Упражнение',
];
8 changes: 5 additions & 3 deletions routes/breadcrumbs.php
Expand Up @@ -5,21 +5,23 @@
use DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs;

Breadcrumbs::for('chapter', function (BreadcrumbsGenerator $trail, \App\Chapter $chapter): void {
$trail->push('Table Of Content', route('chapters.index'));
$trail->push(__('breadcrumb.contents'), route('chapters.index'));

$pushChapters = function (Chapter $chapter) use ($trail, &$pushChapters): void {

if ($chapter->parent) {
$pushChapters($chapter->parent);
}

$trail->push($chapter->path . ' ' . getChapterName($chapter->path), route('chapters.show', $chapter));
$chapterName = getChapterName($chapter->path);
$trail->push("{$chapter->path} {$chapterName}", route('chapters.show', $chapter));
};

$pushChapters($chapter);
});

Breadcrumbs::for('exercise', function (BreadcrumbsGenerator $trail, \App\Exercise $exercise): void {
$trail->parent('chapter', $exercise->chapter);
$trail->push('Exercise ' . $exercise->path, route('exercises.show', $exercise));
$textPart = __('breadcrumb.exercise');
$trail->push("{$textPart} {$exercise->path}", route('exercises.show', $exercise));
});

0 comments on commit ebaec2a

Please sign in to comment.