Skip to content

Commit

Permalink
feat: finalize i18n everywhere (monicahq/chandler#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss authored May 5, 2023
1 parent d6bddda commit 1cbf253
Show file tree
Hide file tree
Showing 318 changed files with 10,909 additions and 4,680 deletions.
2 changes: 1 addition & 1 deletion app/Actions/AttemptToAuthenticateSocialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function authenticateUser(Request $request, string $driver, SocialiteUse
private function checkUserAssociation(Request $request, User $user, string $driver): void
{
if (($userId = Auth::id()) && $userId !== $user->id) {
$this->throwFailedAuthenticationException($request, $driver, __('This provider is already associated with another account'));
$this->throwFailedAuthenticationException($request, $driver, trans('This provider is already associated with another account'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/AttemptToAuthenticateWebauthn.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function throwFailedAuthenticationException(Request $request)
$this->limiter->increment($request);

throw ValidationException::withMessages([
Webauthn::username() => [trans('webauthn::errors.login_failed')],
Webauthn::username() => [trans_ignore('webauthn::errors.login_failed')],
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function update($user, array $input)
'password' => $this->passwordRules(),
])->after(function ($validator) use ($user, $input) {
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add('current_password', __('The provided password does not match your current password.'));
$validator->errors()->add('current_password', trans('The provided password does not match your current password.'));
}
})->validateWithBag('updatePassword');

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/UserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __invoke(Request $request, array $data): array
->filter(fn ($provider) => ! empty($provider))
->mapWithKeys(fn ($provider) => [
$provider => [
'name' => config("services.$provider.name") ?? __("auth.login_provider_{$provider}"),
'name' => config("services.$provider.name") ?? trans_ignore("auth.login_provider_{$provider}"),
'logo' => config("services.$provider.logo") ?? "/img/auth/$provider.svg",
],
]);
Expand Down
32 changes: 32 additions & 0 deletions app/Console/Commands/MonicaLocalize.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 MonicaLocalize extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'monica:localize';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate locale files for Monica.';

/**
* Execute the console command.
*/
public function handle(): void
{
$locales = config('localizer.supported-locales');
array_shift($locales);
$this->call('localize', ['lang' => implode(',', $locales)]);
}
}
2 changes: 1 addition & 1 deletion app/Domains/Contact/Dav/Services/ExportVCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private function exporters()
$namespace = $this->app->getNamespace();
$appPath = app_path();

foreach ((new Finder)->files()->in($appPath)->name('*.php') as $file) {
foreach ((new Finder)->files()->in($appPath)->name('*.php')->notName('helpers.php') as $file) {
$file = $namespace.str_replace(
['/', '.php'],
['\\', ''],
Expand Down
4 changes: 2 additions & 2 deletions app/Domains/Contact/Dav/Services/ImportVCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private function name($entry): string
return (string) $entry->NICKNAME;
}

return (string) __('Unknown contact name');
return (string) trans('Unknown contact name');
}

/**
Expand Down Expand Up @@ -337,7 +337,7 @@ private function importers()
$namespace = $this->app->getNamespace();
$appPath = app_path();

foreach ((new Finder)->files()->in($appPath)->name('*.php') as $file) {
foreach ((new Finder)->files()->in($appPath)->name('*.php')->notName('helpers.php') as $file) {
$file = $namespace.str_replace(
['/', '.php'],
['\\', ''],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function getAddressBookDetails(Vault $vault): array
'id' => $vault->id,
'uri' => $vault->name,
'principaluri' => PrincipalBackend::getPrincipalUser($this->user),
'{DAV:}displayname' => __('Contacts'),
'{DAV:}displayname' => trans('Contacts'),
'{'.CardDAVPlugin::NS_CARDDAV.'}addressbook-description' => $vault->name,
];
if ($token) {
Expand Down
4 changes: 2 additions & 2 deletions app/Domains/Contact/ManageContact/Dav/ImportContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ private function getGender(string $genderCode): Gender
if (! $gender) {
switch ($genderCode) {
case 'M':
$gender = $this->getGenderByName(trans('account.gender_male')) ?? $this->getGenderByName(config('dav.default_gender'));
$gender = $this->getGenderByName(trans('Male')) ?? $this->getGenderByName(config('dav.default_gender'));
break;
case 'F':
$gender = $this->getGenderByName(trans('account.gender_female')) ?? $this->getGenderByName(config('dav.default_gender'));
$gender = $this->getGenderByName(trans('Female')) ?? $this->getGenderByName(config('dav.default_gender'));
break;
default:
$gender = $this->getGenderByName(config('dav.default_gender'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,44 @@ public static function data($items, User $user, Vault $vault): array

private static function getSentence(ContactFeedItem $item): mixed
{
return trans('contact.feed_item_'.$item->action);
return match ($item->action) {
'contact_created' => trans('created the contact'),
'author_deleted' => trans('Deleted author'),
'information_updated' => trans('updated the contact information'),
'important_date_created' => trans('added an important date'),
'important_date_updated' => trans('updated an important date'),
'important_date_destroyed' => trans('deleted an important date'),
'address_created' => trans('added an address'),
'address_updated' => trans('updated an address'),
'address_destroyed' => trans('deleted an address'),
'pet_created' => trans('added a pet'),
'pet_updated' => trans('updated a pet'),
'pet_destroyed' => trans('deleted a pet'),
'contact_information_created' => trans('added a contact information'),
'contact_information_updated' => trans('updated a contact information'),
'contact_information_destroyed' => trans('deleted a contact information'),
'label_assigned' => trans('assigned a label'),
'label_removed' => trans('removed a label'),
'note_created' => trans('wrote a note'),
'note_updated' => trans('edited a note'),
'note_destroyed' => trans('deleted a note'),
'job_information_updated' => trans('updated the job information'),
'religion_updated' => trans('updated the religion'),
'goal_created' => trans('created a goal'),
'goal_updated' => trans('updated a goal'),
'goal_destroyed' => trans('deleted a goal'),
'added_to_group' => trans('added the contact to a group'),
'removed_from_group' => trans('removed the contact from a group'),
'added_to_post' => trans('added the contact to a post'),
'removed_from_post' => trans('removed the contact from a post'),
'archived' => trans('archived the contact'),
'unarchived' => trans('unarchived the contact'),
'favorited' => trans('added the contact to the favorites'),
'unfavorited' => trans('removed the contact from the favorites'),
'changed_avatar' => trans('updated the avatar of the contact'),
'mood_tracking_event_added' => trans('logged the mood'),
default => trans('unknown action'),
};
}

private static function getAuthor(ContactFeedItem $item, Vault $vault): ?array
Expand All @@ -58,7 +95,7 @@ private static function getAuthor(ContactFeedItem $item, Vault $vault): ?array
</svg>';

return [
'name' => trans('contact.feed_item_author_deleted'),
'name' => trans('Deleted author'),
'avatar' => $monicaSvg,
'url' => null,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function data(Contact $contact): array
});
$availableGroupsCollection->prepend([
'id' => 0,
'name' => trans('contact.group_create'),
'name' => trans('+ Create a group'),
'selected' => false,
]);

Expand Down
Loading

0 comments on commit 1cbf253

Please sign in to comment.