diff --git a/README.md b/README.md
index db1e2a5..d6743ee 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# laravel-google-translate
-Translate translation files (under /resources/lang) from specified base locale to all other available languages using google translate api
+Translate translation files (under /resources/lang) from specified base locale to all other available languages using google translate api https://cloud.google.com/translate/
## installation
```console
@@ -28,10 +28,16 @@ php artisan translate:files --baselocale=tr --exclude=auth,passwords --targetloc
https://stackoverflow.com/a/31830614
## suggested packages
-This package can be used with https://github.com/andrey-helldar/laravel-lang-publisher where you have additional translation files to be translated to all other languages
+This package can be used with https://github.com/andrey-helldar/laravel-lang-publisher.
+Example Scenario:
+You would like to add another language support where you have other translation files in addition to base translation files of Laravel. So follow the steps below.
+* Add base Laravel translation files using https://github.com/andrey-helldar/laravel-lang-publisher
+* Translate your custom files using this package
+
+Done
## todo
-* Tranlating one by one takes a long time. Use bulk translate
+* Translating one by one takes a long time. Use bulk translate
## finally
-Thank you for using laravel-google-translate :)
+Thank you for using laravel-google-translate :)
\ No newline at end of file
diff --git a/src/LaravelGoogleTranslateServiceProvider.php b/src/LaravelGoogleTranslateServiceProvider.php
index 759e826..88edcfe 100644
--- a/src/LaravelGoogleTranslateServiceProvider.php
+++ b/src/LaravelGoogleTranslateServiceProvider.php
@@ -2,7 +2,6 @@
namespace Tanmuhittin\LaravelGoogleTranslate;
-
use Illuminate\Support\ServiceProvider;
use Tanmuhittin\LaravelGoogleTranslate\Commands\TranslateFilesCommand;
@@ -34,4 +33,4 @@ public function register()
{
//
}
-}
\ No newline at end of file
+}
diff --git a/src/commands/TranslateFilesCommand.php b/src/commands/TranslateFilesCommand.php
index 3350a52..9c1369f 100644
--- a/src/commands/TranslateFilesCommand.php
+++ b/src/commands/TranslateFilesCommand.php
@@ -6,7 +6,9 @@
class TranslateFilesCommand extends Command
{
- public $locales, $base_locale, $excluded_files;
+ public $locales;
+ public $base_locale;
+ public $excluded_files;
/**
* The name and signature of the console command.
*
@@ -55,8 +57,9 @@ public function handle()
$bar->start();
// loop target locales
foreach ($this->locales as $locale) {
- if ($locale == $this->base_locale)
+ if ($locale == $this->base_locale) {
continue;
+ }
$this->line($this->base_locale . " -> " . $locale . " translating...");
if (is_dir(resource_path('lang/' . $locale))) {
$this->translate_php_array_files($locale);
@@ -92,8 +95,9 @@ private function translate($text, $locale)
if (isset($responseDecoded['error'])) {
$this->error("Google Translate API returned error");
- if (isset($responseDecoded["error"]["message"]))
+ if (isset($responseDecoded["error"]["message"])) {
$this->error($responseDecoded["error"]["message"]);
+ }
exit;
}
@@ -104,16 +108,18 @@ private function translate($text, $locale)
* @param $locale
* @throws \Exception
*/
- private function translate_php_array_files($locale){
+ private function translate_php_array_files($locale)
+ {
$files = preg_grep('/^([^.])/', scandir(resource_path('lang/' . $this->base_locale)));
foreach ($files as $file) {
- if(file_exists(resource_path('lang/' . $locale . '/' . $file . '.php')) && $this->option('preventoverwrite') ){
+ if (file_exists(resource_path('lang/' . $locale . '/' . $file . '.php')) && $this->option('preventoverwrite')) {
$this->line('File already exists: lang/' . $locale . '/' . $file . '.php. Skipping (--preventoverwrite)');
return;
}
$file = substr($file, 0, -4);
- if (in_array($file, $this->excluded_files))
+ if (in_array($file, $this->excluded_files)) {
continue;
+ }
$to_be_translateds = trans($file, [], $this->base_locale);
$new_lang = [];
foreach ($to_be_translateds as $key => $to_be_translated) {
@@ -135,9 +141,10 @@ private function translate_php_array_files($locale){
* @param $locale
* @throws \Exception
*/
- private function translate_json_array_file($locale){
+ private function translate_json_array_file($locale)
+ {
if (file_exists(resource_path('lang/' . $locale . '.json'))) {
- if(file_exists(resource_path('lang/' . $locale . '.json')) && $this->option('preventoverwrite') ){
+ if (file_exists(resource_path('lang/' . $locale . '.json')) && $this->option('preventoverwrite')) {
$this->line('File already exists: lang/' . $locale . '.json. Skipping (--preventoverwrite)');
return;
}
diff --git a/src/laravel_google_translate.php b/src/laravel_google_translate.php
index 1d27868..c3733d3 100644
--- a/src/laravel_google_translate.php
+++ b/src/laravel_google_translate.php
@@ -1,4 +1,4 @@
null,
-];
\ No newline at end of file
+];