Skip to content

feat: Language translations finder and update #7889

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

Closed
wants to merge 15 commits into from

Conversation

neznaika0
Copy link
Contributor

@neznaika0 neznaika0 commented Sep 2, 2023

Description
See thread https://forum.codeigniter.com/showthread.php?tid=88299
Ready to discuss the solution

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 4.5 new feature PRs for new features docs needed Pull requests needing documentation write-ups and/or revisions. labels Sep 2, 2023
@neznaika0
Copy link
Contributor Author

I fixed typehint for PHP 7.4

@kenjis
Copy link
Member

kenjis commented Sep 2, 2023

@kenjis
Copy link
Member

kenjis commented Sep 2, 2023

@neznaika0
Copy link
Contributor Author

neznaika0 commented Sep 2, 2023

There is a conflict between the Rector and php-cs-fixer (pre-commit). The rector erases the indents in the method, and php-cs-fixer adds.

      ---------- begin diff ----------
--- /home/aleksandr/www/codeigniter/tests/system/Commands/Translation/LocalizationFinderTest.php
+++ /home/aleksandr/www/codeigniter/tests/system/Commands/Translation/LocalizationFinderTest.php
@@ -149,33 +149,33 @@
     private function getActualTableWithNewKeys(): string
     {
         return <<<'TEXT_WRAP'
-+------------------+----------------------------------------------------+
-| File             | Key                                                |
-+------------------+----------------------------------------------------+
-| TranslationOne   | TranslationOne.Copyright                           |
...many lines
-| TranslationThree | TranslationThree.formFields.new.short_tag          |
-+------------------+----------------------------------------------------+
-TEXT_WRAP;
+            +------------------+----------------------------------------------------+
+            | File             | Key                                                |
+            +------------------+----------------------------------------------------+
+            | TranslationOne   | TranslationOne.Copyright                           |
...many lines
+            | TranslationThree | TranslationThree.formFields.new.short_tag          |
+            +------------------+----------------------------------------------------+
+            TEXT_WRAP;
     }
 
     private function realizeAssertion(): void

      ----------- end diff -----------

EDIT: Should I move files from Controllers/Translation to another location? This violates the router's tests

@kenjis
Copy link
Member

kenjis commented Sep 2, 2023

The conflict is not a problem. We always need to run composer cs-fix after refactoring by rector.

@kenjis
Copy link
Member

kenjis commented Sep 2, 2023

Should I move files from Controllers/Translation to another location? This violates the router's tests

If possible, it is better.
Or update the failed tests.

@neznaika0
Copy link
Contributor Author

I moved it to another folder with examples.
Added some description in the guide.

Is it possible to get an assessment of the work, is it worth continuing? Or will the function be rejected after the tests?

@kenjis kenjis removed the docs needed Pull requests needing documentation write-ups and/or revisions. label Sep 2, 2023
@kenjis
Copy link
Member

kenjis commented Sep 2, 2023

We have not yet reviewed the contents of the code because the GitHub Action checks have not passed.

However, this feature is useful and I would like to include it in 4.5.

$countNewKeys += $this->arrayCountRecursive($languageDiff);

if ($cliOptionShowNew) {
$tableRows = array_merge($this->arrayToTableRows($langFileName, $languageDiff), $tableRows);
Copy link
Collaborator

@ddevsr ddevsr Sep 3, 2023

Choose a reason for hiding this comment

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

I would like use

Suggested change
$tableRows = array_merge($this->arrayToTableRows($langFileName, $languageDiff), $tableRows);
$tableRows = [$this->arrayToTableRows($langFileName, $languageDiff), $tableRows];

Ref : https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#arraymergeofnonarraystosimplearrayrector

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Read the instructions carefully.
You are trying to merge two arrays, and the documentation talks about strings. This will result in an error.

  • I applied the Rector before the commit

dependabot bot and others added 6 commits September 4, 2023 15:17
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
…hub_actions/actions/checkout-4

build(deps): bump actions/checkout from 3 to 4
@neznaika0
Copy link
Contributor Author

neznaika0 commented Sep 4, 2023

Oops. My commit has merged with the develop branch. Is it ugly? Do I now need a branch from 4.5 and not develop?

I added to PR dashed keys search as lang('Lang-File.dashed.key-with-dash')

@neznaika0 neznaika0 closed this Sep 4, 2023
@neznaika0 neznaika0 deleted the feat-language-finder branch September 14, 2023 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature PRs for new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants