potsky / laravel-localization-helpers

🎌 Artisan commands to generate and update lang files automatically
GNU General Public License v3.0
187 stars 38 forks source link

Question about TODO files in vendor directory #31

Closed rbruhn closed 7 years ago

rbruhn commented 8 years ago

When localization:missing command, there are files generated and placed in the lang/vendor directory. Many of these look like this:

//============================== New strings to translate ==============================//
  // Defined in file /vagrant/biospex/resources/views/frontend/projects/show.blade.php
  'advertise' => 'TODO: advertise',
  // Defined in file /vagrant/biospex/resources/views/frontend/projects/show.blade.php
  'advertiseTitle' => 'TODO: advertiseTitle',

Which refers to this:

<button title="@lang('buttons.advertiseTitle')" class="btn btn-success btn-sm" type="button"
                    onClick="location.href='{{ route('web.advertises.index', [$project->id]) }}'"><span
                        class="fa fa-globe fa-lrg"></span> @lang('buttons.advertise')</button>

And is clearly present in the lang/en/buttons.php file that is generated:

  //==================================== Translations ====================================//
  'advertise' => 'Advertise',
  'advertiseTitle' => 'Advertise this project in external websites',

So, I'm wondering why this is telling me I have a TODO when it already exists?

potsky commented 7 years ago

Hi @rbruhn,

I am sorry not to have been able to get back to you sooner. The behaviour you describe is anormal. What command do you execute ?

Could you send me your lang/en/buttons.php file please ?

cdarken commented 7 years ago

Just noticed the same behavior. I have this in a model: trans('messages.status.new') and the translation is generated in resources/lang/en/messages.php but also in resources/lang/vendor/messages.php.

potsky commented 7 years ago

Hi @cdarken,

this is normal because the extension thinks that the vendor folder name is a lang name. So it generates a messages.php lang file...

Why do you have a vendor lang folder ? Is it a laraval convention that I have missed ?

cdarken commented 7 years ago

The resources/lang/vendor folder is for overriding the translations belonging to the packages.

Docs: https://laravel.com/docs/5.3/localization#overriding-package-language-files

potsky commented 7 years ago

Oops :-)

So I really need to remove it from the folder scan !

cdarken commented 7 years ago

Or maybe, if it's not very complicated, you could search for namespaces specific to the vendors (those separated by ::) and update the translations if there are new strings, what do you say? Only if the translations are copied from the package.

potsky commented 7 years ago

Good idea. This is supported in 4.2 so it is a global feature, nice.

How to you write the trans lemma for a package ?

potsky commented 7 years ago

I will exclude the vendor folder in the next version and will implement vendor translation in the v3. I need to rewrite the extension to do this.