laravel-google-translate
laravel-google-translate copied to clipboard
Should handle resources/views/vendor/$package/ and resources/lang/vendor/$package/lang.json
- currently views in resources/views/vendor/$package are being ingored
- 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+");
The workaround that worked at least to have the views, but is kinda fiddly has been:
-
mv resources/views/vendor/$the-package-name resources/views/$the-package-name
- alter
JsonArrayFileTranslator
to write to a seperate directory (e.g. lang/test/lang.json) - run
php artisan translate:files
-
mv resources/views/$the-package-name resources/views/vendor/$the-package-name
- copy lang/test/lang.json to lang/vendor/$the-package-name/lang.json
done
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
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();