Skip to content

Commit

Permalink
Merge pull request #244 from fey/fix/exercises-page-translates
Browse files Browse the repository at this point in the history
fix chapter translate on exercises.index
  • Loading branch information
fey committed May 13, 2020
2 parents d034b81 + 6c0739e commit 9859968
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 3 deletions.
17 changes: 17 additions & 0 deletions app/Helpers/ExerciseHelper.php
@@ -1,9 +1,26 @@
<?php

use App\Exercise;

if (!function_exists('getExerciseListingViewFilepath')) {
function getExerciseListingViewFilepath(string $exercisePath): string
{
$viewName = str_replace('.', '_', $exercisePath);
return sprintf('exercise.listing.%s', $viewName);
}
}

if (!function_exists('getExerciseTitle')) {
function getExerciseTitle(Exercise $exercise): ?string
{
$underscoredPath = str_replace('.', '_', $exercise->path);

$titleTranslatePath = "exercises/{$underscoredPath}.title";

if (Lang::has($titleTranslatePath)) {
return __($titleTranslatePath);
}

return null;
}
}
1 change: 1 addition & 0 deletions resources/lang/en/exercises/1_1.php
@@ -1,6 +1,7 @@
<?php

return [
'title' => 'Sequence of expressions',
'description' =>
'Below is a sequence of expressions. ' .
'What is the result printed by the interpreter in response to each expression? ' .
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/exercises/1_2.php
@@ -1,5 +1,6 @@
<?php

return [
'title' => 'Into prefix form',
'description' => 'Translate the following expression into prefix form:'
];
1 change: 1 addition & 0 deletions resources/lang/en/exercises/1_3.php
@@ -1,5 +1,6 @@
<?php

return [
'title' => 'Sum of the squares',
'description' => 'Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.'
];
1 change: 1 addition & 0 deletions resources/lang/en/exercises/1_4.php
@@ -1,6 +1,7 @@
<?php

return [
'title' => 'Composite expressions',
'description' =>
'Observe that our model of evaluation allows for combinations whose operators are compound expressions. ' .
'Use this observation to describe the behavior of the following procedure:',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/exercises/1_5.php
@@ -1,6 +1,7 @@
<?php

return [
'title' => 'Calculation order',
'description' => [
'1' =>
'Ben Bitdiddle has invented a test to determine whether the interpreter ' .
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/ru/chapter.php
@@ -1,7 +1,7 @@
<?php

return [
'chapter' => 'Chapter',
'chapter' => 'Глава',
'show' => [
'exercises_list' => 'Упражнения',
'no_exercises' => 'Упражнений нет',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/ru/exercises/1_1.php
@@ -1,6 +1,7 @@
<?php

return [
'title' => 'Последовательность выражений',
'description' =>
'Ниже приведена последовательность выражений. ' .
'Какой результат напечатает интерпретатор в ответ на каждое из них? ' .
Expand Down
1 change: 1 addition & 0 deletions resources/lang/ru/exercises/1_2.php
@@ -1,5 +1,6 @@
<?php

return [
'title' => 'В префиксной форме',
'description' => 'Переведите следующее выражение в префиксную форму:'
];
1 change: 1 addition & 0 deletions resources/lang/ru/exercises/1_3.php
@@ -1,5 +1,6 @@
<?php

return [
'title' => 'Сумма квадратов',
'description' => 'Определите процедуру, которая принимает в качестве аргументов три числа и возвращает сумму квадратов двух больших из них.'
];
1 change: 1 addition & 0 deletions resources/lang/ru/exercises/1_4.php
@@ -1,6 +1,7 @@
<?php

return [
'title' => 'Составные выражения',
'description' =>
'Заметим, что наша модель вычислений разрешает существование комбинаций, операторы кото-рых — составные выражения. ' .
'С помощью этого наблюдения опишите, как работает следующаяпроцедура:',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/ru/exercises/1_5.php
@@ -1,6 +1,7 @@
<?php

return [
'title' => 'Порядок вычислений',
'description' => [
'1' =>
'Бен Битобор придумал тест для проверки интерпретатора на то, ' .
Expand Down
4 changes: 2 additions & 2 deletions resources/views/exercise/index.blade.php
Expand Up @@ -20,7 +20,7 @@
href="#subChapters{{ $rootChapterPath }}" data-toggle="tab" role="tab"
aria-controls="subChapters{{ $rootChapterPath }}"
aria-selected="{{ $rootChapterPath === '1' ? 'true' : 'false' }}">
{{ __('chapter.chapter') }} {{ $rootChapterPath }}
{{$rootChapterPath}}. {{ getChapterName($rootChapterPath) }}
</a>
@endforeach
</div>
Expand All @@ -36,7 +36,7 @@
@foreach($exercises as $exercise)
<a title="{{ __('exercise.exercise') }} {{ $exercise->path }}"
href="{{ route('exercises.show', $exercise) }}">
{{ $exercise->path }}
{{ $exercise->path }} {{ getExerciseTitle($exercise) }}
<br>
</a>
@endforeach
Expand Down

0 comments on commit 9859968

Please sign in to comment.