Skip to content

Commit

Permalink
Merge pull request #157 from galdazbiz/languages
Browse files Browse the repository at this point in the history
Languages integration - English and Spanish
  • Loading branch information
marktopper authored Jan 18, 2018
2 parents 08f9775 + cf6bb36 commit 805a1e9
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 83 deletions.
34 changes: 0 additions & 34 deletions config/chatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@
'login' => 'login',
],

/*
|--------------------------------------------------------------------------
| Forum Titles
|--------------------------------------------------------------------------
|
| These are some default titles (words) that will be used throughout your
| forum. You can change these to whatever you would like :)
|
*/

'titles' => [
'discussion' => 'Discussion',
'discussions' => 'Discussions',
'category' => 'Category',
],

/*
|--------------------------------------------------------------------------
| The main headline and description of your forum
Expand Down Expand Up @@ -151,24 +135,6 @@
'avatar_image_database_field' => '',
],

/*
|--------------------------------------------------------------------------
| Alert Message Titles
|--------------------------------------------------------------------------
|
| When a user successfully adds a new discussion or they do something wrong
| they will get an alert message. Based on the alert message there is a
| specific title message for every alert, which are defined below.
|
*/

'alert_messages' => [
'success' => 'Well done!',
'info' => 'Heads Up!',
'warning' => 'Wuh Oh!',
'danger' => 'Oh Snap!',
],

/*
|--------------------------------------------------------------------------
| A Few security measures to prevent spam on your forum
Expand Down
6 changes: 6 additions & 0 deletions src/ChatterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ChatterServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadTranslationsFrom(__DIR__.'/Lang', 'chatter');
$this->publishes([
__DIR__.'/../public/assets' => public_path('vendor/devdojo/chatter/assets'),
], 'chatter_assets');
Expand All @@ -28,6 +29,11 @@ public function boot()
$this->publishes([
__DIR__.'/../database/seeds/' => database_path('seeds'),
], 'chatter_seeds');

$this->publishes([
__DIR__.'/Lang' => resource_path('lang/vendor/chatter'),
], 'chatter_lang');

// include the routes file
include __DIR__.'/Routes/web.php';
}
Expand Down
12 changes: 7 additions & 5 deletions src/Controllers/ChatterDiscussionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ public function store(Request $request)

if (config('chatter.security.limit_time_between_posts')) {
if ($this->notEnoughTimeBetweenDiscussion()) {
$minute_copy = (config('chatter.security.time_between_posts') == 1) ? ' minute' : ' minutes';
$minutes = trans_choice('chatter::messages.words.minutes', config('chatter.security.time_between_posts'));
$chatter_alert = [
'chatter_alert_type' => 'danger',
'chatter_alert' => 'In order to prevent spam, please allow at least '.config('chatter.security.time_between_posts').$minute_copy.' in between submitting content.',
'chatter_alert' => trans('chatter::alert.danger.reason.prevent_spam', [
'minutes' => $minutes,
]),
];

return redirect('/'.config('chatter.routes.home'))->with($chatter_alert)->withInput();
Expand Down Expand Up @@ -142,15 +144,15 @@ public function store(Request $request)

$chatter_alert = [
'chatter_alert_type' => 'success',
'chatter_alert' => 'Successfully created a new '.config('chatter.titles.discussion').'.',
'chatter_alert' => trans('chatter::alert.success.reason.created_discussion'),
];

return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$slug)->with($chatter_alert);
} else {
$chatter_alert = [
'chatter_alert_type' => 'danger',
'chatter_alert' => 'Whoops :( There seems to be a problem creating your '.config('chatter.titles.discussion').'.',
];
'chatter_alert' => trans('chatter::alert.danger.reason.create_discussion'),
];

return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$slug)->with($chatter_alert);
}
Expand Down
20 changes: 11 additions & 9 deletions src/Controllers/ChatterPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ public function store(Request $request)

if (config('chatter.security.limit_time_between_posts')) {
if ($this->notEnoughTimeBetweenPosts()) {
$minute_copy = (config('chatter.security.time_between_posts') == 1) ? ' minute' : ' minutes';
$minutes = trans_choice('chatter::messages.words.minutes', config('chatter.security.time_between_posts'));
$chatter_alert = [
'chatter_alert_type' => 'danger',
'chatter_alert' => 'In order to prevent spam, please allow at least '.config('chatter.security.time_between_posts').$minute_copy.' in between submitting content.',
'chatter_alert' => trans('chatter::alert.danger.reason.prevent_spam', [
'minutes' => $minutes,
]),
];

return back()->with($chatter_alert)->withInput();
Expand Down Expand Up @@ -106,14 +108,14 @@ public function store(Request $request)

$chatter_alert = [
'chatter_alert_type' => 'success',
'chatter_alert' => 'Response successfully submitted to '.config('chatter.titles.discussion').'.',
'chatter_alert' => trans('chatter::alert.success.reason.submitted_to_post'),
];

return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$discussion->slug)->with($chatter_alert);
} else {
$chatter_alert = [
'chatter_alert_type' => 'danger',
'chatter_alert' => 'Sorry, there seems to have been a problem submitting your response.',
'chatter_alert' => trans('chatter::alert.danger.reason.trouble'),
];

return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$discussion->slug)->with($chatter_alert);
Expand Down Expand Up @@ -176,14 +178,14 @@ public function update(Request $request, $id)

$chatter_alert = [
'chatter_alert_type' => 'success',
'chatter_alert' => 'Successfully updated the '.config('chatter.titles.discussion').'.',
'chatter_alert' => trans('chatter::alert.success.reason.updated_post'),
];

return redirect('/'.config('chatter.routes.home').'/'.config('chatter.routes.discussion').'/'.$category->slug.'/'.$discussion->slug)->with($chatter_alert);
} else {
$chatter_alert = [
'chatter_alert_type' => 'danger',
'chatter_alert' => 'Nah ah ah... Could not update your response. Make sure you\'re not doing anything shady.',
'chatter_alert' => trans('chatter::alert.danger.reason.update_post'),
];

return redirect('/'.config('chatter.routes.home'))->with($chatter_alert);
Expand All @@ -205,7 +207,7 @@ public function destroy($id, Request $request)
if ($request->user()->id !== (int) $post->user_id) {
return redirect('/'.config('chatter.routes.home'))->with([
'chatter_alert_type' => 'danger',
'chatter_alert' => 'Nah ah ah... Could not delete the response. Make sure you\'re not doing anything shady.',
'chatter_alert' => trans('chatter::alert.danger.reason.destroy_post'),
]);
}

Expand All @@ -220,7 +222,7 @@ public function destroy($id, Request $request)

return redirect('/'.config('chatter.routes.home'))->with([
'chatter_alert_type' => 'success',
'chatter_alert' => 'Successfully deleted the response and '.strtolower(config('chatter.titles.discussion')).'.',
'chatter_alert' => trans('chatter::alert.success.reason.destroy_post'),
]);
}

Expand All @@ -230,7 +232,7 @@ public function destroy($id, Request $request)

return redirect($url)->with([
'chatter_alert_type' => 'success',
'chatter_alert' => 'Successfully deleted the response from the '.config('chatter.titles.discussion').'.',
'chatter_alert' => trans('chatter::alert.success.reason.destroy_from_discussion'),
]);
}
}
31 changes: 31 additions & 0 deletions src/Lang/en/alert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

return [
'success' => [
'title' => 'Well done!',
'reason' => [
'submitted_to_post' => 'Response successfully submitted to discussion.',
'updated_post' => 'Successfully updated the Discussion.',
'destroy_post' => 'Successfully deleted the response and discussion.',
'destroy_from_discussion' => 'Successfully deleted the response from the discussion.',
'created_discussion' => 'Successfully created a new discussion.',
],
],
'info' => [
'title' => 'Heads Up!',
],
'warning' => [
'title' => 'Wuh Oh!',
],
'danger' => [
'title' => 'Oh Snap!',
'reason' => [
'errors' => 'Please fix the following errors:',
'prevent_spam' => 'In order to prevent spam, please allow at least :minutes in between submitting content.',
'trouble' => 'Sorry, there seems to have been a problem submitting your response.',
'update_post' => 'Nah ah ah... Could not update your response. Make sure you\'re not doing anything shady.',
'destroy_post' => 'Nah ah ah... Could not delete the response. Make sure you\'re not doing anything shady.',
'create_discussion' => 'Whoops :( There seems to be a problem creating your discussion.',
],
],
];
14 changes: 14 additions & 0 deletions src/Lang/en/email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [
'preheader' => 'Just wanted to let you know that someone has responded to a forum post.',
'greeting' => 'Hi there,',
'body' => 'Just wanted to let you know that someone has responded to a forum post at',
'view_discussion' => 'View The Discussion',
'farewell' => 'Have a great day!',
'unsuscribe' => [
'message' => 'If you no longer wish to be notified when someone responds to this form post be sure to uncheck the notification setting at the bottom of the page :)',
'action' => 'Don\'t like these emails?',
'link' => 'Unsubscribe to this Discussion',
],
];
44 changes: 44 additions & 0 deletions src/Lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

return [
'words' => [
'cancel' => 'Cancel',
'delete' => 'Delete',
'edit' => 'Edit',
'yes' => 'Yes',
'no' => 'No',
'minutes' => '1 minute| :count minutes',
],

'discussion' => [
'new' => 'New Discussion',
'all' => 'All Discussions',
'create' => 'Create Discussion',
'posted_by' => 'Posted by',
'head_details' => 'Posted in Category',

],
'response' => [
'confirm' => 'Are you sure you want to delete this response?',
'yes_confirm' => 'Yes Delete It',
'no_confirm' => 'No Thanks',
'submit' => 'Submit response',
'update' => 'Update Response',
],

'editor' => [
'title' => 'Title of Discussion',
'select' => 'Select a Category',
'tinymce_placeholder' => 'Type Your Discussion Here...',
'select_color_text' => 'Select a Color for this Discussion (optional)',
],

'email' => [
'notify' => 'Notify me when someone replies',
],

'auth' => 'Please <a href="/:home/login">login</a>
or <a href="/:home/register">register</a>
to leave a response.',

];
31 changes: 31 additions & 0 deletions src/Lang/es/alert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

return [
'success' => [
'title' => '¡Bien hecho!',
'reason' => [
'submitted_to_post' => 'Respuesta enviada correctamente a la discusión.',
'updated_post' => 'Discusión actualizada correctamente.',
'destroy_post' => 'Se ha borrado correctamente la respuesta y la discusión.',
'destroy_from_discussion' => 'Se ha borrado correctamente la respuesta de la discusión.',
'created_discussion' => 'Se ha creado correctamente una nueva discusión.',
],
],
'info' => [
'title' => '¡Aviso!',
],
'warning' => [
'title' => '¡Precaución!',
],
'danger' => [
'title' => '¡Ha ocurrido un error!',
'reason' => [
'errors' => 'Por favor corrige los siguientes errores:',
'prevent_spam' => 'Con el fin de prevenir el SPAM, podrás volver a enviar el contenido nuevamente en :minutes',
'trouble' => 'Parece que ha ocurrido un problema al intentar enviar la respuesta, vuelve a intentarlo más tarde.',
'update_post' => '¡Oh! No se ha podido actualizar la respuesta.',
'destroy_post' => '¡Oh! No se ha podido borrar la respuesta.',
'create_discussion' => '¡Ups! Parece que hay un problema al crear la discusión. :(',
],
],
];
14 changes: 14 additions & 0 deletions src/Lang/es/email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [
'preheader' => 'Este texto es como un encabezado. Algunos clientes muestran este texto como una vista previa.',
'greeting' => 'Hola,',
'body' => 'Te informamos que alguien ha respondido a una discusión publicada en',
'view_discussion' => 'Ver la discusión',
'farewell' => 'Que tengas un buen día.',
'unsuscribe' => [
'message' => 'Si ya no deseas ser notificado cuando alguien más responda, asegurate de desmarcar la configuración de notificación al final de la página :)',
'action' => '¿No le gustan estos correos electrónicos?',
'link' => 'Anular la suscripción a la discusión',
],
];
44 changes: 44 additions & 0 deletions src/Lang/es/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

return [
'words' => [
'cancel' => 'Cancelar',
'delete' => 'Borrar',
'edit' => 'Editar',
'yes' => 'Si',
'no' => 'No',
'minutes' => '1 minuto| :count minutos',
],

'discussion' => [
'new' => 'Nueva Discusión',
'all' => 'Todas las discusiones',
'create' => 'Crear una discusión',
'posted_by' => 'Publicado por',
'head_details' => 'Publicado en categoria',

],
'response' => [
'confirm' => '¿Estás seguro de que quieres borrar la respuesta?',
'yes_confirm' => 'Si, borrar',
'no_confirm' => 'No gracias',
'submit' => 'Enviar respuesta',
'update' => 'Actualizar respuesta',
],

'editor' => [
'title' => 'Titulo de la discusión',
'select' => 'Selecciona una categoria',
'tinymce_placeholder' => 'Agrega el contenido para la discusión aquí...',
'select_color_text' => 'Selecciona un color para la discusión (opcional)',
],

'email' => [
'notify' => 'Notificarme cuando alguien conteste en la discusión',
],

'auth' => 'Por favor <a href="/:home/login">Inicia sesión</a>
o <a href="/:home/register">Regístrate</a>
para dejar una respuesta.',

];
Loading

0 comments on commit 805a1e9

Please sign in to comment.