Skip to content

Commit 2513c8b

Browse files
committed
Installing and using the localization component
1 parent 9f00866 commit 2513c8b

File tree

8 files changed

+191
-10
lines changed

8 files changed

+191
-10
lines changed

app/Http/Controllers/TicketsController.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class TicketsController extends Controller {
1111
public function latest()
1212
{
1313
$tickets = Ticket::orderBy('created_at', 'DESC')->paginate(20);
14-
$title = 'Solicitudes recientes';
15-
return view('tickets/list', compact('tickets', 'title'));
14+
return view('tickets/list', compact('tickets'));
1615
}
1716

1817
public function popular()
@@ -23,15 +22,13 @@ public function popular()
2322
public function open()
2423
{
2524
$tickets = Ticket::where('status', 'open')->orderBy('created_at', 'DESC')->paginate(20);
26-
$title = 'Solicitudes abiertas';
27-
return view('tickets/list', compact('tickets', 'title'));
25+
return view('tickets/list', compact('tickets'));
2826
}
2927

3028
public function closed()
3129
{
3230
$tickets = Ticket::where('status', 'closed')->orderBy('created_at', 'DESC')->paginate(20);
33-
$title = 'Tutoriales';
34-
return view('tickets/list', compact('tickets', 'title'));
31+
return view('tickets/list', compact('tickets'));
3532
}
3633

3734
public function details($id)

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
|
5353
*/
5454

55-
'locale' => 'en',
55+
'locale' => 'es',
5656

5757
/*
5858
|--------------------------------------------------------------------------

resources/lang/es/pagination.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Pagination Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines are used by the paginator library to build
11+
| the simple pagination links. You are free to change them to anything
12+
| you want to customize your views to better match your application.
13+
|
14+
*/
15+
16+
'previous' => '&laquo; Anterior',
17+
18+
'next' => 'Siguiente &raquo;',
19+
20+
];

resources/lang/es/passwords.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Password Reminder Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines are the default lines which match reasons
11+
| that are given by the password broker for a password update attempt
12+
| has failed, such as for an invalid token or invalid new password.
13+
|
14+
*/
15+
16+
"password" => "Las contraseñas deben contener al menos 6 caracteres y coincidir.",
17+
18+
"user" => "No podemos encontrar a un usuario con ese correo electrónico.",
19+
20+
"token" => "Este token de recuperación de contraseña es inválido.",
21+
22+
"sent" => "¡Recordatorio de contraseña enviado!",
23+
24+
"reset" => "¡Tu contraseña ha sido restablecida!",
25+
26+
];

resources/lang/es/tickets.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
return array(
4+
5+
'latest_title' => 'Solicitudes recientes',
6+
'open_title' => 'Solicitudes abiertas',
7+
'closed_title' => 'Tutoriales',
8+
'popular_title' => 'Solicitudes populares',
9+
10+
'latest_total' => '{0} No hay solicitudes recientes'
11+
. '|{1} Sólo hay una solicitud reciente'
12+
. '|[2,Inf] Hay :count solicitudes recientes',
13+
14+
'open_total' => '{0} No hay solicitudes abiertas'
15+
. '|{1} Sólo hay una solicitud abierta'
16+
. '|[2,Inf] Hay :count solicitudes abiertas',
17+
18+
'closed_total' => '{0} No hay tutoriales'
19+
. '|{1} Sólo hay un tutorial'
20+
. '|[2,Inf] Hay :count tutoriales',
21+
22+
'popular_total' => '{0} No hay solicitudes populares'
23+
. '|{1} Sólo hay una solicitud popular'
24+
. '|[2,Inf] Hay :count solicitudes populares',
25+
26+
'status' => array(
27+
'open' => 'Abierta',
28+
'closed' => 'Finalizada'
29+
)
30+
31+
);

resources/lang/es/validation.php

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Validation Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines contain the default error messages used by
11+
| the validator class. Some of these rules have multiple versions such
12+
| such as the size rules. Feel free to tweak each of these messages.
13+
|
14+
*/
15+
16+
"accepted" => ":attribute debe ser aceptado.",
17+
"active_url" => ":attribute no es una URL válida.",
18+
"after" => ":attribute debe ser una fecha posterior a :date.",
19+
"alpha" => ":attribute solo debe contener letras.",
20+
"alpha_dash" => ":attribute solo debe contener letras, números y guiones.",
21+
"alpha_num" => ":attribute solo debe contener letras y números.",
22+
"array" => ":attribute debe ser un conjunto.",
23+
"before" => ":attribute debe ser una fecha anterior a :date.",
24+
"between" => [
25+
"numeric" => ":attribute tiene que estar entre :min - :max.",
26+
"file" => ":attribute debe pesar entre :min - :max kilobytes.",
27+
"string" => ":attribute tiene que tener entre :min - :max caracteres.",
28+
"array" => ":attribute tiene que tener entre :min - :max ítems.",
29+
],
30+
"boolean" => "El campo :attribute debe tener un valor verdadero o falso.",
31+
"confirmed" => "La confirmación de :attribute no coincide.",
32+
"date" => ":attribute no es una fecha válida.",
33+
"date_format" => ":attribute no corresponde al formato :format.",
34+
"different" => ":attribute y :other deben ser diferentes.",
35+
"digits" => ":attribute debe tener :digits dígitos.",
36+
"digits_between" => ":attribute debe tener entre :min y :max dígitos.",
37+
"email" => ":attribute no es un correo válido",
38+
"exists" => ":attribute es inválido.",
39+
"filled" => "El campo :attribute es obligatorio.",
40+
"image" => ":attribute debe ser una imagen.",
41+
"in" => ":attribute es inválido.",
42+
"integer" => ":attribute debe ser un número entero.",
43+
"ip" => ":attribute debe ser una dirección IP válida.",
44+
"max" => [
45+
"numeric" => ":attribute no debe ser mayor a :max.",
46+
"file" => ":attribute no debe ser mayor que :max kilobytes.",
47+
"string" => ":attribute no debe ser mayor que :max caracteres.",
48+
"array" => ":attribute no debe tener más de :max elementos.",
49+
],
50+
"mimes" => ":attribute debe ser un archivo con formato: :values.",
51+
"min" => [
52+
"numeric" => "El tamaño de :attribute debe ser de al menos :min.",
53+
"file" => "El tamaño de :attribute debe ser de al menos :min kilobytes.",
54+
"string" => ":attribute debe contener al menos :min caracteres.",
55+
"array" => ":attribute debe tener al menos :min elementos.",
56+
],
57+
"not_in" => ":attribute es inválido.",
58+
"numeric" => ":attribute debe ser numérico.",
59+
"regex" => "El formato de :attribute es inválido.",
60+
"required" => "El campo :attribute es obligatorio.",
61+
"required_if" => "El campo :attribute es obligatorio cuando :other es :value.",
62+
"required_with" => "El campo :attribute es obligatorio cuando :values está presente.",
63+
"required_with_all" => "El campo :attribute es obligatorio cuando :values está presente.",
64+
"required_without" => "El campo :attribute es obligatorio cuando :values no está presente.",
65+
"required_without_all" => "El campo :attribute es obligatorio cuando ninguno de :values estén presentes.",
66+
"same" => ":attribute y :other deben coincidir.",
67+
"size" => [
68+
"numeric" => "El tamaño de :attribute debe ser :size.",
69+
"file" => "El tamaño de :attribute debe ser :size kilobytes.",
70+
"string" => ":attribute debe contener :size caracteres.",
71+
"array" => ":attribute debe contener :size elementos.",
72+
],
73+
"timezone" => "El :attribute debe ser una zona válida.",
74+
"unique" => ":attribute ya ha sido registrado.",
75+
"url" => "El formato :attribute es inválido.",
76+
77+
/*
78+
|--------------------------------------------------------------------------
79+
| Custom Validation Language Lines
80+
|--------------------------------------------------------------------------
81+
|
82+
| Here you may specify custom validation messages for attributes using the
83+
| convention "attribute.rule" to name the lines. This makes it quick to
84+
| specify a specific custom language line for a given attribute rule.
85+
|
86+
*/
87+
88+
'custom' => [
89+
'attribute-name' => [
90+
'rule-name' => 'custom-message',
91+
],
92+
],
93+
94+
/*
95+
|--------------------------------------------------------------------------
96+
| Custom Validation Attributes
97+
|--------------------------------------------------------------------------
98+
|
99+
| The following language lines are used to swap attribute place-holders
100+
| with something more reader friendly such as E-Mail Address instead
101+
| of "email". This simply helps us make messages a little cleaner.
102+
|
103+
*/
104+
105+
'attributes' => [],
106+
107+
];

resources/views/tickets/list.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<div class="col-md-10 col-md-offset-1">
88
<div class="row">
99
<h1>
10-
{{ $title }}
10+
{{ $title = trans(Route::currentRouteName() . '_title') }}
1111
<a href="#" class="btn btn-primary">
1212
Nueva solicitud
1313
</a>
1414
</h1>
1515

1616
<p class="label label-info news">
17-
Hay {{ $tickets->total() }} {{ $title }}
17+
{{ Lang::choice(Route::currentRouteName() . '_total', $tickets->total()) }}
1818
</p>
1919

2020
@foreach($tickets as $ticket)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<span{!! Html::classes(['label label-info absolute', 'highlight' => $ticket->open]) !!}>
2-
{{ $ticket->status }}
2+
{{ trans('tickets.status.' . $ticket->status) }}
33
</span>

0 commit comments

Comments
 (0)