Skip to content

Commit

Permalink
Test with suffix
Browse files Browse the repository at this point in the history
Removed language scripts
  • Loading branch information
PG-Momik committed Feb 1, 2023
1 parent 636df43 commit 8d32c64
Show file tree
Hide file tree
Showing 202 changed files with 5,886 additions and 3,775 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ supervisord.log
supervisord.pid
secret.yaml
github-credentials.yaml
/storage/lang/data/
32 changes: 32 additions & 0 deletions app/Console/Commands/GenerateLanguageBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class GenerateLanguageBase extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
return 0;
}
}
32 changes: 32 additions & 0 deletions app/Console/Commands/GenerateLanguageFiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class GenerateLanguageFiles extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
return 0;
}
}
4 changes: 2 additions & 2 deletions app/CsvImporter/Entities/Activity/Components/ActivityRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ protected function countDuplicateActivityIdentifiers($rows): int
protected function containsDuplicateTransactions($references): bool
{
if ((!empty($references)) && (count(array_unique($references)) !== count($references))) {
$this->errors['transactions']['transactions.reference'] = 'There are duplicate Transactions for this Activity in the uploaded Csv File.';
$this->errors['transactions']['transactions.reference'] = trans('common.error.there_are_duplicate_transactions_for_activity');

return true;
}
Expand All @@ -691,7 +691,7 @@ protected function containsDuplicateTransactions($references): bool
protected function containsDuplicateActivities($commonIdentifierCount): bool
{
if ($commonIdentifierCount > 1) {
$this->errors['activity_identifier']['activity_identifier'] = 'This Activity has been duplicated in the uploaded Csv File.';
$this->errors['activity_identifier']['activity_identifier'] = trans('common.error.this_activity_has_been_duplicated');

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function rules(): array
public function messages(): array
{
$messages = $this->getBaseMessages($this->request->getMessagesForCondition(Arr::get($this->data, 'conditions.condition', [])), false);
$messages['conditions.condition_attached.in'] = 'The condition attached value is invalid.';
$messages['conditions.condition_attached.in'] = trans('common.error.condition_attached_value_is_invalid');

return $messages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function rules(): array
*/
public function messages(): array
{
$messages['activity_title.0.narrative.required'] = 'The activity title is required.';
$messages['activity_title.0.narrative.required'] = trans('common.error.activity_title_is_required');

return $messages;
}
Expand Down
4 changes: 2 additions & 2 deletions app/CsvImporter/Queue/Exceptions/HeaderMismatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class HeaderMismatchException extends Exception
/**
* Message for the HeaderMismatch Exception.
*/
public const MESSAGE = 'The headers in the uploaded Csv file do not match with the provided template.';
public $message;

/**
* HeaderMismatchException constructor.
*/
public function __construct()
{
$this->message = self::MESSAGE;
$this->message = trans('common.error.header_mismatch_exception');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function update(LegacyDataRequest $request, $id): JsonResponse|RedirectRe
{
try {
if ($this->activityLegacyDataService->update($id, $request->all())) {
return redirect()->route('admin.activity.show', $id)->with('success', 'Legacy-data updated successfully.');
return redirect()->route('admin.activity.show', $id)->with('success', trans('responses.event_successfully', [':prefix'=>ucfirst(trans('elements_common.legacy_data')), ':event'=>trans('elements_common.updated')]));
}

return redirect()->route('admin.activity.show', $id)->with('error', trans('responses.error_has_occurred', ['event'=>trans('responses.updating'), 'suffix'=>trans('elements_common.legacy_data')]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function status(): View|RedirectResponse

if ($schema_error) {
Session::put('error', $status['message'] . '. To see errors <b>
<a href=' . awsUrl(sprintf('%s/%s/%s', $filetype === 'xml' ? $this->xml_data_storage_path : $this->csv_data_storage_path, $orgId, 'schema_error.log')) . ' target="_blank">Open Error File</a></b>');
<a href=' . awsUrl(sprintf('%s/%s/%s', $filetype === 'xml' ? $this->xml_data_storage_path : $this->csv_data_storage_path, $orgId, 'schema_error.log')) . ' target="_blank">trans("responses.open_error_file")</a></b>');

return redirect()->route('admin.activities.index');
}
Expand Down
40 changes: 21 additions & 19 deletions app/Http/Controllers/Admin/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function index(): View|RedirectResponse
} catch (\Exception $e) {
logger()->error($e->getMessage());

return redirect()->back()->with('error', 'Error has occurred while rendering user listing page');
return redirect()->back()->with('error', trans('responses.error_has_occurred_page', [':event'=>trans('events.rendering'), ':suffix'=>trans('user.user_listing')]));
}
}

Expand All @@ -99,12 +99,12 @@ public function store(UserRequest $request): JsonResponse
$this->userService->store($formData);
$this->db->commit();

return response()->json(['success' => true, 'message' => 'New user successfully created.']);
return response()->json(['success' => true, 'message' => trans('event_successfully', [':event'=>trans('events.created'), 'prefix'=>trans('user.new_user')])]);
} catch (\Exception $e) {
$this->db->rollback();
logger()->error($e->getMessage());

return response()->json(['success' => false, 'message' => 'Error has occurred while creating user.']);
return response()->json(['success' => false, 'message' => trans('responses.error_has_occurred', [':event'=>trans('events.creating'), ':suffix'=>lcfirst(trans('user.user'))])]);
}
}

Expand All @@ -128,12 +128,12 @@ public function update(UserUpdateRequest $request, $id): JsonResponse
$this->userService->update($id, $formData);
$this->db->commit();

return response()->json(['success' => true, 'message' => 'User has been updated successfully.']);
return response()->json(['success' => true, 'message' => trans('event_successfully', [':event'=>trans('events.updated'), 'prefix'=>trans('user.user')])]);
} catch (\Exception $e) {
$this->db->rollback();
logger()->error($e->getMessage());

return response()->json(['success' => false, 'message' => 'Error has occurred while updating user.']);
return response()->json(['success' => false, 'message' => trans('responses.error_has_occurred', [':event'=>trans('events.updating'), ':suffix'=>lcfirst(trans('user.user'))])]);
}
}

Expand All @@ -147,14 +147,14 @@ public function delete(int $id): JsonResponse
{
try {
if ($this->userService->delete($id)) {
return response()->json(['success' => true, 'message' => 'User has been deleted successfully.']);
return response()->json(['success' => true, 'message' => trans('event_successfully', [':event'=>trans('events.deleted'), 'prefix'=>trans('user.user')])]);
}

return response()->json(['success' => false, 'message' => 'The user cannot be deleted.']);
return response()->json(['success' => false, 'message' => trans('user.cannot_be_deleted')]);
} catch (\Exception $e) {
logger()->error($e->getMessage());

return response()->json(['success' => false, 'message' => 'Error has occurred while deleting user.']);
return response()->json(['success' => false, 'message' => trans('responses.error_has_occurred', [':event'=>trans('events.deleting'), ':suffix'=>lcfirst(trans('user.user'))])]);
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ public function showUserProfile(): View|RedirectResponse
} catch (\Exception $e) {
logger()->error($e->getMessage());

return redirect()->route('admin.activities.index')->with('error', 'Error while rendering setting page');
return redirect()->route('admin.activities.index')->with('error', trans('responses.error_has_occurred_page', [':event'=>trans('events.rendering'), ':suffix'=>lcfirst(trans('settings.settings_label'))]));
}
}

Expand All @@ -244,15 +244,15 @@ public function getPaginatedUsers(Request $request, int $page = 1): JsonResponse

return response()->json([
'success' => true,
'message' => 'Paginated users fetch successfully.',
'message' => trans('user.paginated_users_fetched'),
'data' => $users,
]);
} catch (\Exception $e) {
logger()->error($e->getMessage());

return response()->json([
'success' => false,
'message' => 'Error occurred while trying to get paginated user.',
'message' => trans('user.error_occurred_while'),
]);
}
}
Expand Down Expand Up @@ -321,21 +321,21 @@ public function updatePassword(UserProfileRequest $request): JsonResponse
$formData = $request->only(['current_password', 'password']);

if (!Hash::check($formData['current_password'], Auth::user()->getAuthPassword())) {
return response()->json(['success' => false, 'errors' => ['current_password' => ['Please enter correct current password']]]);
return response()->json(['success' => false, 'errors' => ['current_password' => [trans('register.correct_current')]]]);
}

$this->userService->updatePassword(Auth::user()->id, $formData);

return response()->json([
'success' => true,
'message' => 'Password updated successfully.',
'message' => trans('event_successfully', [':event'=>trans('events.updated'), 'prefix'=>trans('register.password.label')]),
]);
} catch (\Exception $e) {
logger()->error($e->getMessage());

return response()->json([
'success' => false,
'message' => 'Error occurred while updating password.',
'message' => trans('responses.error_has_occurred', [':event'=>trans('events.updating'), ':suffix'=>lcfirst(trans('register.password.label'))]),
]);
}
}
Expand All @@ -359,15 +359,15 @@ public function updateProfile(UserProfileRequest $request): JsonResponse

return response()->json([
'success' => true,
'message' => 'User profile updated successfully.',
'message' => trans('event_successfully', [':event'=>trans('events.updated'), 'prefix'=>trans('user.user_profile')]),
]);
} catch (\Exception $e) {
$this->db->rollback();
logger()->error($e->getMessage());

return response()->json([
'success' => false,
'message' => 'Error occurred while updating user profile.',
'message' => trans('responses.error_has_occurred', [':event'=>trans('events.updating'), ':suffix'=>lcfirst(trans('user.user_profile'))]),
]);
}
}
Expand All @@ -385,16 +385,18 @@ public function toggleUserStatus($id): JsonResponse
$user = $this->userService->getUser($id);

if ($this->userService->toggleUserStatus($id)) {
return response()->json(['success' => true, 'message' => $user->status ? 'User has been deactivated successfully.' : 'User has been activated successfully.']);
return response()->json(['success' => true, 'message' => $user->status
? trans('event_successfully', [':event'=>trans('events.deactivated'), 'prefix'=>trans('user.user')])
: trans('event_successfully', [':event'=>trans('events.activated'), 'prefix'=>trans('user.user')]), ]);
}

return response()->json(['success' => false, 'message' => 'The status of this user cannot be changed.']);
return response()->json(['success' => false, 'message' => trans('user.status_cannot_be_changed')]);
} catch (\Exception $e) {
logger()->error($e->getMessage());

return response()->json([
'success' => false,
'message' => 'Error has occurred while trying to toggle user status',
'message' => trans('responses.error_has_occurred', [':event'=>trans('events.toggle'), ':suffix'=>lcfirst(trans('responses.user_status'))]),
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function publish($id): JsonResponse
DB::beginTransaction();
$this->activityWorkflowService->publishActivity($activity);
DB::commit();
Session::put('success', 'Activity has been published successfully.');
Session::put('success', trans('event_successfully', [':event'=>trans('events.published'), 'prefix'=>ucfirst(trans('elements_common.activity'))]));

return response()->json(['success' => true, 'message' => ucfirst(trans('responses.has_been_event_successfully', ['prefix'=>trans('elements_common.activity'), 'event'=>trans('responses.published')]))]);
} catch (PublisherNotFound $message) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function logout(Request $request): JsonResponse|RedirectResponse
}

return $request->wantsJson()
? new JsonResponse(['status' => true, 'message' => 'Successfully logged out.'], 204)
? new JsonResponse(['status' => true, 'message' => trans('user.successfully_logged_out')], 204)
: redirect('/');
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/User/UserProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function messages(): array
$form_type = $this->get('form_type');

if ($form_type === 'password') {
$messages['publisher_id.regex'] = 'The publisher id is invalid. The publisher id must be at least two characters long and lower case. It can include letters, numbers and also - (dash) and _ (underscore).';
$messages['publisher_id.regex'] = trans('user.publisher_id_is_invalid');
} else {
$messages['username.regex'] = 'The username is invalid. Username must be purely lowercase alphabets followed by alphanumeric(ascii) characters and these symbols:-_';
$messages['username.regex'] = trans('username_is_invalid');
}

return $messages;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/User/UserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function decryptPassword(): void
*/
public function messages(): array
{
$messages['username.regex'] = 'The username is invalid. Username must be purely lowercase alphabets followed by alphanumeric(ascii) characters and these symbols:-_';
$messages['username.regex'] = trans('user.username_is_invalid');

return $messages;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/User/UserUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function rules(): array
*/
public function messages(): array
{
$messages['username.regex'] = 'The username is invalid. Username must be purely lowercase alphabets followed by alphanumeric(ascii) characters and these symbols:-_';
$messages['username.regex'] = trans('user.username_is_invalid');

return $messages;
}
Expand Down
4 changes: 2 additions & 2 deletions app/IATI/Elements/Xml/ArrayToXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static function &convert($node_name, $arr = [])
if (isset($arr['@attributes'])) {
foreach ($arr['@attributes'] as $key => $value) {
if (!self::isValidTagName($key)) {
throw new \Exception('[Array2XML] Illegal character in attribute name. attribute: ' . $key . ' in node: ' . $node_name);
throw new \Exception('[Array2XML]' . trans('common.error.illegal_character_in_attribute_name') . ': ' . $key . ' ' . trans('common.in_node') . ': ' . $node_name);
}

$node->setAttribute($key, self::bool2str($value));
Expand Down Expand Up @@ -98,7 +98,7 @@ private static function &convert($node_name, $arr = [])
// recurse to get the node for that key
foreach ($arr as $key => $value) {
if (!self::isValidTagName($key)) {
throw new \Exception('[Array2XML] Illegal character in tag name. tag: ' . $key . ' in node: ' . $node_name);
throw new \Exception('[Array2XML] ' . trans('common.error.illegal_character_in_tag_name') . ': ' . $key . ' ' . trans('common.in_node') . ': ' . $node_name);
}

if (is_array($value) && is_numeric(key($value))) {
Expand Down
13 changes: 6 additions & 7 deletions app/IATI/Models/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public static function sendEmail(): void
{
VerifyEmail::toMailUsing(function ($notifiable, $url) {
return (new MailMessage)
->subject(trans('common.sendEmail.verify_email_address'))
->greeting(trans('common.sendEmail.hello') . $notifiable->full_name)
->line(trans('common.sendEmail.line'))
->action(trans('common.sendEmail.verify_email_address'), $url);
->subject(trans('common.send_email.verify_email_address'))
->greeting(trans('common.send_email.hello') . ' ' . $notifiable->full_name)
->line(trans('common.send_email.welcome_to_iati') . ' ' . trans('common.send_email.verify_that_you_have_created_the_account'))
->action(trans('common.send_email.verify_email_address'), $url);
});
}

Expand All @@ -146,9 +146,8 @@ public static function sendEmail(): void
public static function sendNewUserEmail($user): void
{
$mailDetails = [
'greeting' => 'Hello ' . $user->username,
'message' => 'Welcome to IATI Publisher. Your email has been used to create a new account here.
Please click the button below to update the password of your account.',
'greeting' => trans('common.send_email.hello') . ' ' . $user->username,
'message' => trans('common.send_email.welcome_to_iati') . ' ' . trans('common.send_email.update_the_password_of_your_account'),
'password_update' => true,
'token' => app('auth.password.broker')->createToken($user),
];
Expand Down
Loading

0 comments on commit 8d32c64

Please sign in to comment.