tanmuhittin / laravel-google-translate

Translate translation files to other languages using google translate or another translation api
MIT License
424 stars 71 forks source link

Translate vendor language files (php) #49

Closed underdpt closed 2 years ago

underdpt commented 3 years ago

This PR enable the translation of php language files under resource/lang/vendor.

It modifies some core functions from PhpArrayFileTranslator.php:

I also made some cosmetic changes for better readability.

NOTE: this is only for php lang files. I don't know any package that ships with a json translation file under /vendor/ so this is missing translating vendor json files. If you know such package, please tell me so I can add a PR for that so the package is consistent.

tanmuhittin commented 3 years ago

Thank you for the good work! PR looks fine. Needs to be tested. Could you add a unit test for this case?

underdpt commented 3 years ago

Yeah, i can add it to testTranslatePhpFilesCommand() or make a new testTranslateVendorPhpFilesCommand() that would be almost a 1-1 copy. What would you prefer?

tanmuhittin commented 3 years ago

you can add it to existing one. testTranslatePhpFilesCommand

underdpt commented 3 years ago

Just added it.

Also I found that the target folder might not exists when running the tests, so added a check for that.

tanmuhittin commented 3 years ago

I will test locally and merge it this weekend. Good job. Thank you for your contribution!

tanmuhittin commented 3 years ago

Tests are not passing. Please check


There was 1 failure:

1) Tanmuhittin\LaravelGoogleTranslateTests\Unit\TranslateFilesCommandTest::testTranslatePhpFilesCommand
Failed asserting that file "/Users/karabas/Desktop/laravel-google-translate/tests/Unit/../test-resources/resources/lang/tr/tests.php" exists.

/Users/karabas/Desktop/laravel-google-translate/tests/Unit/TranslateFilesCommandTest.php:22
`
``
underdpt commented 3 years ago

I've just checked. My developmen OS is Windows, and it seems the regex to filter the paths chokes on unix or mixed folder separator. I've upgraded the function to search the lang files to always use unix paths and corrected the regex.

vahidalvandi commented 2 years ago

so i need this

vahidalvandi commented 2 years ago

thanks