Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Some translations have been lost in the new version (10.0) #1762

Merged
merged 23 commits into from Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/main/Processors/Packages.php
Expand Up @@ -10,6 +10,7 @@ final class Packages extends Processor
protected array $packages = [
'laravel/fortify' => 'packages/fortify.json',
'laravel/jetstream' => 'packages/jetstream.json',
'laravel/framework' => 'en.json',
];

public function run(): void
Expand Down
23 changes: 14 additions & 9 deletions app/main/Support/Finder.php
Expand Up @@ -11,43 +11,48 @@ class Finder

protected array $names = ['*.php', '*.json', '*.js', '*.vue'];

protected array $contains = ['__(', 'trans(', '@lang(', 'Lang::get('];
protected array $contains = ['__(', 'trans(', '@lang(', 'Lang::get(', '->fail('];

protected array $files = [];

public function __construct(
protected SymfonyFinder $instance
protected SymfonyFinder $finder
) {
}

public function get(string|array $path): array
{
$this->search($path);

return $this->files();
return $this->files($path);
}

protected function search(string|array $path): void
{
foreach ($this->find($path) as $file) {
$this->push($file->getRealPath());
$this->push($path, $file->getRealPath());
}
}

protected function find(string|array $path): SymfonyFinder
{
return $this->instance->in($path)->files()
return $this->finder()->in($path)->files()
->name($this->names)
->contains($this->contains);
}

protected function push(string $path): void
protected function push(string|array $source, string $path): void
{
$this->files[] = $path;
$this->files[$source][] = $path;
}

protected function files(): array
protected function files(string|array $path): array
{
return $this->files;
return $this->files[$path] ?? [];
}

protected function finder(): SymfonyFinder
{
return clone $this->finder;
}
}
4 changes: 2 additions & 2 deletions app/main/Support/Package.php
Expand Up @@ -9,7 +9,7 @@ class Package
{
protected ?string $path;

protected array $filter = ['$this', 'self::', 'auth.', 'pagination.', 'passwords.', 'validation.'];
protected array $filter = ['$', 'self::', 'static::', 'auth.', 'pagination.', 'passwords.', 'validation.'];

public function __construct(
protected Finder $finder,
Expand Down Expand Up @@ -52,6 +52,6 @@ protected function parsed(array $files): array

protected function filter(array $items): array
{
return array_filter(array_keys($items), fn ($value) => ! Str::startsWith($value, $this->filter));
return array_filter(array_keys($items), fn ($value) => ! Str::contains($value, $this->filter));
}
}
22 changes: 17 additions & 5 deletions app/main/Support/Parser.php
Expand Up @@ -10,7 +10,7 @@ class Parser
{
use Makeable;

protected const REGEX = '/\b(__|trans|@lang|Lang\:\:get)\((.+)(\)|,\s?\[)/U';
protected const REGEX = '/\b(__|trans|lang|Lang\:\:get|fail)\(\r*\s*(.+)\r*\s*(\)|,\s?\[)/U';

protected array $files = [];

Expand All @@ -25,12 +25,18 @@ public function files(array $files): self

public function get(): array
{
$this->clear();
$this->each();
$this->sort();

return $this->keys();
}

protected function clear(): void
{
$this->keys = [];
}

protected function each(): void
{
foreach ($this->files as $file) {
Expand All @@ -50,10 +56,12 @@ protected function parse(string $content): void
foreach ($this->match($content) as $match) {
$value = $match;

if (Str::contains((string) $value, ['__', 'trans', '@lang', 'Lang::get'])) {
if (Str::contains((string) $value, ['__', 'trans', '@lang', 'Lang::get', '->fail('])) {
$sub_key = $this->subkey($value);

$value = $this->keys[$sub_key] ?? null;
$sub_value = $this->keys[$sub_key] ?? null;

$this->push($sub_value);
}

$this->push($value);
Expand Down Expand Up @@ -90,8 +98,12 @@ protected function keys(): array

protected function trim($value)
{
$chars = " \t\n\r\0\x0B'\"";
if (is_string($value)) {
$chars = " \t\n\r\0\x0B'\"";

return trim(stripslashes($value), $chars);
}

return is_string($value) ? trim($value, $chars) : $value;
return $value;
}
}
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -27,6 +27,7 @@
"andrey-helldar/support": "^3.16.1",
"guzzlehttp/guzzle": "^7.3",
"laravel/fortify": "^1.7",
"laravel/framework": "^8.43",
"laravel/jetstream": "^2.3",
"phpunit/phpunit": "^9.5",
"symfony/finder": "^5.2",
Expand Down
30 changes: 8 additions & 22 deletions source/en.json
@@ -1,29 +1,20 @@
{
"A fresh verification link has been sent to your email address.": "A fresh verification link has been sent to your email address.",
"Before proceeding, please check your email for a verification link.": "Before proceeding, please check your email for a verification link.",
"click here to request another": "click here to request another",
"E-Mail Address": "E-Mail Address",
"All rights reserved.": "All rights reserved.",
"Forbidden": "Forbidden",
"Go Home": "Go Home",
"Go to page :page": "Go to page :page",
"Hello!": "Hello!",
"If necessary, you may logout of all of your other browser sessions across all of your devices. Some of your recent sessions are listed below; however, this list may not be exhaustive. If you feel your account has been compromised, you should also update your password.": "If necessary, you may logout of all of your other browser sessions across all of your devices. Some of your recent sessions are listed below; however, this list may not be exhaustive. If you feel your account has been compromised, you should also update your password.",
"If you did not create an account, no further action is required.": "If you did not create an account, no further action is required.",
"If you did not receive the email": "If you did not receive the email",
"If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser:": "If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser:",
"Invalid signature.": "Invalid signature.",
"Log out": "Log out",
"Logout Other Browser Sessions": "Logout Other Browser Sessions",
"Manage and logout your active sessions on other browsers and devices.": "Manage and logout your active sessions on other browsers and devices.",
"Nevermind": "Nevermind",
"If you did not request a password reset, no further action is required.": "If you did not request a password reset, no further action is required.",
"Not Found": "Not Found",
"of": "of",
"Oh no": "Oh no",
"Page Expired": "Page Expired",
"Pagination Navigation": "Pagination Navigation",
"Please click the button below to verify your email address.": "Please click the button below to verify your email address.",
"Please confirm your password before continuing.": "Please confirm your password before continuing.",
"Please enter your password to confirm you would like to logout of your other browser sessions across all of your devices.": "Please enter your password to confirm you would like to logout of your other browser sessions across all of your devices.",
"Please provide the email address of the person you would like to add to this team. The email address must be associated with an existing account.": "Please provide the email address of the person you would like to add to this team. The email address must be associated with an existing account.",
"Regards": "Regards",
"Reset Password": "Reset Password",
"Reset Password Notification": "Reset Password Notification",
"results": "results",
"Server Error": "Server Error",
"Service Unavailable": "Service Unavailable",
Expand All @@ -33,16 +24,11 @@
"The :attribute must contain at least one symbol.": "The :attribute must contain at least one symbol.",
"The :attribute must contain at least one uppercase and one lowercase letter.": "The :attribute must contain at least one uppercase and one lowercase letter.",
"The given :attribute has appeared in a data leak. Please choose a different :attribute.": "The given :attribute has appeared in a data leak. Please choose a different :attribute.",
"This action is unauthorized.": "This action is unauthorized.",
andrey-helldar marked this conversation as resolved.
Show resolved Hide resolved
"This password reset link will expire in :count minutes.": "This password reset link will expire in :count minutes.",
"to": "to",
"Toggle navigation": "Toggle navigation",
"Too Many Attempts.": "Too Many Attempts.",
"Too Many Requests": "Too Many Requests",
"Unauthorized": "Unauthorized",
"Verify Email Address": "Verify Email Address",
"Verify Your Email Address": "Verify Your Email Address",
"We won't ask for your password again for a few hours.": "We won't ask for your password again for a few hours.",
"You are logged in!": "You are logged in!",
"Your email address is not verified.": "Your email address is not verified."
"Whoops!": "Whoops!",
"You are receiving this email because we received a password reset request for your account.": "You are receiving this email because we received a password reset request for your account."
}
23 changes: 6 additions & 17 deletions source/packages/jetstream.json
Expand Up @@ -79,7 +79,7 @@
"Photo": "Photo",
"Please confirm access to your account by entering one of your emergency recovery codes.": "Please confirm access to your account by entering one of your emergency recovery codes.",
"Please confirm access to your account by entering the authentication code provided by your authenticator application.": "Please confirm access to your account by entering the authentication code provided by your authenticator application.",
"Please copy your new API token. For your security, it won\\'t be shown again.": "Please copy your new API token. For your security, it won\\'t be shown again.",
"Please copy your new API token. For your security, it won't be shown again.": "Please copy your new API token. For your security, it won't be shown again.",
"Please enter your password to confirm you would like to log out of your other browser sessions across all of your devices.": "Please enter your password to confirm you would like to log out of your other browser sessions across all of your devices.",
"Please provide the email address of the person you would like to add to this team.": "Please provide the email address of the person you would like to add to this team.",
"Privacy Policy": "Privacy Policy",
Expand Down Expand Up @@ -108,20 +108,9 @@
"Team Owner": "Team Owner",
"Team Settings": "Team Settings",
"Terms of Service": "Terms of Service",
"Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\\'t receive the email, we will gladly send you another.": "Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\\'t receive the email, we will gladly send you another.",
"Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn't receive the email, we will gladly send you another.": "Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn't receive the email, we will gladly send you another.",
"The :attribute must be a valid role.": "The :attribute must be a valid role.",
"The :attribute must be at least :length characters and contain at least one number.": "The :attribute must be at least :length characters and contain at least one number.",
"The :attribute must be at least :length characters and contain at least one special character and one number.": "The :attribute must be at least :length characters and contain at least one special character and one number.",
"The :attribute must be at least :length characters and contain at least one special character.": "The :attribute must be at least :length characters and contain at least one special character.",
"The :attribute must be at least :length characters and contain at least one uppercase character and one number.": "The :attribute must be at least :length characters and contain at least one uppercase character and one number.",
"The :attribute must be at least :length characters and contain at least one uppercase character and one special character.": "The :attribute must be at least :length characters and contain at least one uppercase character and one special character.",
"The :attribute must be at least :length characters and contain at least one uppercase character, one number, and one special character.": "The :attribute must be at least :length characters and contain at least one uppercase character, one number, and one special character.",
"The :attribute must be at least :length characters and contain at least one uppercase character.": "The :attribute must be at least :length characters and contain at least one uppercase character.",
"The :attribute must be at least :length characters.": "The :attribute must be at least :length characters.",
"The provided password does not match your current password.": "The provided password does not match your current password.",
"The provided password was incorrect.": "The provided password was incorrect.",
"The provided two factor authentication code was invalid.": "The provided two factor authentication code was invalid.",
"The team\\'s name and owner information.": "The team\\'s name and owner information.",
"The team's name and owner information.": "The team's name and owner information.",
"These people have been invited to your team and have been sent an invitation email. They may join the team by accepting the email invitation.": "These people have been invited to your team and have been sent an invitation email. They may join the team by accepting the email invitation.",
"This device": "This device",
"This is a secure area of the application. Please confirm your password before continuing.": "This is a secure area of the application. Please confirm your password before continuing.",
Expand All @@ -130,13 +119,13 @@
"This user has already been invited to the team.": "This user has already been invited to the team.",
"Token Name": "Token Name",
"Two Factor Authentication": "Two Factor Authentication",
"Two factor authentication is now enabled. Scan the following QR code using your phone\\'s authenticator application.": "Two factor authentication is now enabled. Scan the following QR code using your phone\\'s authenticator application.",
"Two factor authentication is now enabled. Scan the following QR code using your phone's authenticator application.": "Two factor authentication is now enabled. Scan the following QR code using your phone's authenticator application.",
"Update Password": "Update Password",
"Update your account\\'s profile information and email address.": "Update your account\\'s profile information and email address.",
"Update your account's profile information and email address.": "Update your account's profile information and email address.",
"Use a recovery code": "Use a recovery code",
"Use an authentication code": "Use an authentication code",
"We were unable to find a registered user with this email address.": "We were unable to find a registered user with this email address.",
"When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone\\'s Google Authenticator application.": "When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone\\'s Google Authenticator application.",
"When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Google Authenticator application.": "When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Google Authenticator application.",
"Whoops! Something went wrong.": "Whoops! Something went wrong.",
"You have been invited to join the :team team!": "You have been invited to join the :team team!",
"You have enabled two factor authentication.": "You have enabled two factor authentication.",
Expand Down