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

Should handle resources/views/vendor/$package/ and resources/lang/vendor/$package/lang.json #44

Open
momente-organisieren opened this issue Apr 27, 2021 · 7 comments

Comments

@momente-organisieren
Copy link

momente-organisieren commented Apr 27, 2021

  1. currently views in resources/views/vendor/$package are being ingored
  2. lang.json is only written to resources/lang/lang.json

proposed outcome

  • Finder scans resoures/views/vendor/$package
  • collects strings
  • strings get translated
  • JsonArrayFileTranslator writes to resoureces/lang/vendor/$package/lang.json

additional notes

laravel doc suggests to publish vendor packages to resources/lang/vendor/$vendor/lang.json

translations genarated by laravel-google-translate that have been read from `resources/vendor/$package/lang.json should also be written to this target.

now only lang/lang.json is supported and used

JsonArrayFileTranslator.php#L46

$file = fopen(resource_path('lang/' . $target_locale . '.json'), "w+");
@momente-organisieren momente-organisieren changed the title Should handle vendor/lang.json Should handle vendor/$vendor/lang.json Apr 27, 2021
@momente-organisieren momente-organisieren changed the title Should handle vendor/$vendor/lang.json Should handle vendor/$package/lang.json Apr 27, 2021
@momente-organisieren momente-organisieren changed the title Should handle vendor/$package/lang.json Should handle resources/views/vendor/$package/ and resources/lang/vendor/$package/lang.json Apr 27, 2021
@momente-organisieren
Copy link
Author

momente-organisieren commented Apr 27, 2021

The workaround that worked at least to have the views, but is kinda fiddly has been:

  1. mv resources/views/vendor/$the-package-name resources/views/$the-package-name
  2. alter JsonArrayFileTranslator to write to a seperate directory (e.g. lang/test/lang.json)
  3. run php artisan translate:files
  4. mv resources/views/$the-package-name resources/views/vendor/$the-package-name
  5. copy lang/test/lang.json to lang/vendor/$the-package-name/lang.json

done

@momente-organisieren
Copy link
Author

on that journey another fine option would be to specify only a source lang.json and to skip the whole file reader work that parses views and controllers .. maybe as a Console Command flag

@itsrexb
Copy link

itsrexb commented Aug 8, 2022

The problem here is that it ignores any(?) directory named "vendor"
In /src/TranslationFileTranslators/JsonArrayFileTranslator.php line 103 replace the line below and it will work
$finder->in(base_path())->exclude('storage')->exclude('vendor')->in(base_path().DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'vendor')->name('*.php')->name('*.twig')->name('*.vue')->files();

itsrexb added a commit to itsrexb/laravel-google-translate that referenced this issue Aug 8, 2022
@itsrexb
Copy link

itsrexb commented Apr 15, 2024

There's a security issue here that needs to be applied immediately 0777 permission is too open
https://github.com/tanmuhittin/laravel-google-translate/pull/58/files#diff-227ca57210f13336f78c103af73ea7fd5f5cf04337a0425a827acce83cbe51b5L62

@Umar-Farooq-Shafi
Copy link

Is there any workaround using php files?

@itsrexb
Copy link

itsrexb commented Jun 3, 2024

Is there any workaround using php files?

you can use my PR here #44 (comment)

@Umar-Farooq-Shafi
Copy link

@itsrexb Does it work with the .php extension inside the lang/vendor/filament-actions/en directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants