Skip to content

Conversation

@neznaika0
Copy link
Contributor

Description
Superseds #8149

  • Add filepath in list bad keys
  • Add natural sorting output values (bad keys)
$ ./spark lang:find --verbose

...

Files found: 10
New translates found: 30
Bad translates found: 5
+------------------------+---------------------------------+
| Bad Key                | Filepath                        |
+------------------------+---------------------------------+
| ..invalid_nested_key.. | app/Controllers/Translation.php |
| .invalid_key           | app/Controllers/Translation.php |
| TranslationBad         | app/Controllers/Translation.php |
| TranslationBad.        | app/Controllers/Translation.php |
| TranslationBad...      | app/Controllers/Translation.php |
+------------------------+---------------------------------+

All operations done!

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added enhancement PRs that improve existing functionalities 4.5 labels Dec 4, 2023
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may not get something here... This command is described as:

Find and save available phrases to translate

Why does it suddenly show the wrong language keys? And how does it know which keys are bad?

@neznaika0
Copy link
Contributor Author

Have you read the previous issue? @kenjis and I thought it would be worthwhile to warn the user when scanning that there are incorrect keys.
It still does its function. Only additionally notifies about it

Look at the output. Which keys are bad?

  • They do not start with the file name (dots).
  • Have duplicate dots at the beginning\at the end.
  • They have only the file name (one line, without dots).

In short, anything that does not fall under the correct File.key, File.nested.key format

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now I get it. Thanks.

}

$fileContent = file_get_contents($file->getRealPath());
preg_match_all('/lang\(\'([._a-z0-9\-]+)\'\)/ui', $fileContent, $matches);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one feature: The regular expression initially discards bad keys. They will not be shown in the list.

@kenjis kenjis merged commit 778f18e into codeigniter4:4.5 Dec 8, 2023
@kenjis
Copy link
Member

kenjis commented Dec 8, 2023

@neznaika0 Thank you!

@neznaika0 neznaika0 deleted the lang-find-show-bad-keys branch May 6, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PRs that improve existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants