email localization fix

This commit is contained in:
Čarodej
2022-07-15 12:19:48 +02:00
parent bc5300ad6d
commit c323677cfa
10 changed files with 44 additions and 19457 deletions

View File

@@ -1,6 +1,6 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:O3Cn1MQIeqjOtDEcU8L8FBB50VHqqr6vyBeCN3Qn47U=
APP_KEY=base64:wc7BQuWSAASCWebDAs/DPlMmLdYVm/fI434nwhZqMm0=
APP_DEBUG=true
APP_URL=http://localhost
APP_DEMO=false
@@ -18,7 +18,7 @@ FILESYSTEM_DISK=local
BROADCAST_DRIVER=null
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_LIFETIME="15120"
SCOUT_DRIVER=tntsearch
REDIS_HOST=127.0.0.1

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
<?php
return [
'version' => '2.2.1',
'version' => '2.2.2',
'is_demo' => env('APP_DEMO', false),

View File

@@ -75,15 +75,15 @@ class AppServiceProvider extends ServiceProvider
private function setLocale(): void
{
try {
$app_locale = get_settings('language') ?? 'en';
$appLocale = get_settings('language') ?? 'en';
} catch (\PDOException $e) {
$app_locale = 'en';
$appLocale = 'en';
}
// Set locale for application
app()->setLocale($app_locale);
app()->setLocale($appLocale);
// Set locale for carbon dates
setlocale(LC_TIME, $app_locale . '_' . mb_strtoupper($app_locale));
setlocale(LC_TIME, $appLocale . '_' . mb_strtoupper($appLocale));
}
}

View File

@@ -92,6 +92,11 @@ class User extends Authenticatable implements MustVerifyEmail
return UserFactory::new();
}
public function preferredLocale(): string
{
return get_settings('language') ?? 'en';
}
/**
* Get user used storage details
*/

View File

@@ -19,25 +19,27 @@ class UpdateSettingValueController extends Controller
'message' => 'The value was successfully updated',
];
$inputName = $request->input('name');
// Abort in demo mode
if (is_demo()) {
return response()->json($message);
}
// Store image if exist
if ($request->hasFile($request->input('name'))) {
if ($request->hasFile($inputName)) {
// Find and update image path
Setting::updateOrCreate([
'name' => $request->input('name'),
'name' => $inputName,
], [
'value' => store_system_image($request, $request->input('name')),
'value' => store_system_image($request, $inputName),
]);
return response()->json($message);
}
// Set paypal live option
if ($request->input('name') === 'paypal_live') {
if ($inputName === 'paypal_live') {
setEnvironmentValue([
'PAYPAL_IS_LIVE' => $request->input('value') ? 'true' : 'false',
]);
@@ -51,9 +53,14 @@ class UpdateSettingValueController extends Controller
return response()->json($message);
}
// Clear language cache
if ($inputName === 'language') {
cache()->forget('language');
}
// Find and update variable
Setting::updateOrCreate(
['name' => $request->input('name')],
['name' => $inputName],
['value' => $request->input('value')]
);

View File

@@ -15,9 +15,14 @@ class SendViaEmailAction
string $token,
User $user,
): void {
// Get default app locale
$appLocale = get_settings('language') ?? 'en';
foreach ($emails as $email) {
Notification::route('mail', $email)
->notify(new SharedSendViaEmail($token, $user));
->notify(
(new SharedSendViaEmail($token, $user))->locale($appLocale)
);
}
}
}

View File

@@ -36,8 +36,13 @@ class InviteMembersIntoTeamFolderAction
// Invite guest
if (! $user) {
// Get default app locale
$appLocale = get_settings('language') ?? 'en';
Notification::route('mail', $member['email'])
->notify(new InvitationIntoTeamFolder($folder, $invitation));
->notify(
(new InvitationIntoTeamFolder($folder, $invitation))->locale($appLocale)
);
}
});
}

View File

@@ -44,8 +44,13 @@ class CreateUploadRequestController extends Controller
if ($user) {
$user->notify(new UploadRequestNotification($uploadRequest));
} else {
// Get default app locale
$appLocale = get_settings('language') ?? 'en';
Notification::route('mail', $uploadRequest->email)
->notify(new UploadRequestNotification($uploadRequest));
->notify(
(new UploadRequestNotification($uploadRequest))->locale($appLocale)
);
}
}

View File

@@ -178,6 +178,7 @@ class UserAccountTest extends TestCase
'canDownload' => true,
'canInviteTeamMembers' => true,
'canUpload' => true,
'reason' => null,
],
],
'relationships' => [
@@ -235,7 +236,7 @@ class UserAccountTest extends TestCase
->getJson($verificationUrl)
->assertRedirect('successfully-verified');
$this->assertNotNull(User::find($user->id)->get('email_verified_at'));
$this->assertNotNull(User::find($user->id)->email_verified_at);
}
/**