Closed sporchia closed 6 years ago
Thanks, but cannot merge this until failure is fixed.
Class App needs to be imported.
Corrected the failing tests
should be all good to go
I am not sure I fully understand the intent of this change. Could you please demonstrate the issue being solved with a test case.
In case it helps, here is a slightly more detailed textual description of the issue this pull request is trying to solve.
Imagine a Laravel project with the following files: resources/lang/en/general.php:
<?php
return [
‘projectTitle’ => 'My Project',
];
resources/lang/en/mainpage.php:
<?php
return [
‘page_title’ => __('general.projectName'),
];
resources/lang/en/otherpage.php:
<?php
return [
‘page_title’ => __('general.projectName') . ' - Other',
];
resources/lang/fr/general.php:
<?php
return [
‘projectTitle’ => 'Mon Projet',
];
resources/lang/fr/mainpage.php:
<?php
return [
‘page_title’ => __('general.projectName'),
];
resources/lang/fr/otherpage.php:
<?php
return [
‘page_title’ => __('general.projectName') . ' - Autre',
];
(Please pardon my google translate quality French.)
In Laravel proper __('otherpage.page_tile')
will resolve to "My Project - Other" for English, and "Mon Projet - Autre" for French, while __('mainpage.page_title')
will become "My Project" and "Mon Project" respectively.
The translations php artisan vue-i18n:generate
currently generates for French are:
general.projectTitle
=> "Mon Projet"
mainpage.page_title
=> "My Project"
otherpage.page_title
=> "My Project - Autre"
Obviously that is not exactly French. This pull request fixes that.
As for why you would want to do something like this? Well a variety of reasons, such as ensuring consistency of terminology throughout a localization. The important thing is that Laravel is fine with it, as long as you avoiding translation files referencing each other in a loop.
Thanks, I understand the problem better now. Having a hard time myself to come up with a test case because of how the tests currently are structured.
Are you positive this works for you? I just want to ensure the code actually does anything, as the test failed with App not available and you solved that by checking for existance of App, thus making it a no-op if App is not there.
I am not sure the App facade is around when you run the php artisan vue-i18n:generate
command.
I went ahead and pushed this. Still a bit confused of what is the proper way to access the app instance from the package.
e.g. if you have a file:
it is translated to the base locale and not the current locale, this should fix that.
I didn't see a contributing section, so I hope this is helpful, and gets merged.