laravel-translation
laravel-translation copied to clipboard
When I try to open any language to edit translations
I did change to php 7.3 this problem appears each time i try to enter single language page to edit translation
// JoeDixon\Translation\Drivers\Translation::JoeDixon\Translation\Drivers{closure}(): Argument #2 ($key) must be passed by reference, value given
This happens with PHP 8.0. (It did not happen with PHP7.4) This issue is caused with the following method getSourceLanguageTranslationsWith()
in vendor/joedixon/laravel-translation/src/Drivers/Translation.php
.
public function getSourceLanguageTranslationsWith($language)
{
$sourceTranslations = $this->allTranslationsFor($this->sourceLanguage);
$languageTranslations = $this->allTranslationsFor($language);
return $sourceTranslations->map(function ($groups, $type) use ($language, $languageTranslations) {
return $groups->map(function ($translations, $group) use ($type, $language, $languageTranslations) {
$translations = $translations->toArray();
array_walk($translations, function (&$value, &$key) use ($type, $group, $language, $languageTranslations) {
$value = [
$this->sourceLanguage => $value,
$language => $languageTranslations->get($type, collect())->get($group, collect())->get($key),
];
});
return $translations;
});
});
}
Problem Area: function (&$value, &$key)
array_walk($translations, function (&$value, &$key) use ($type, $group, $language, $languageTranslations) {
......
});
How to Fix: Drop &
from &$key
. That will make it work.
public function getSourceLanguageTranslationsWith($language)
{
$sourceTranslations = $this->allTranslationsFor($this->sourceLanguage);
$languageTranslations = $this->allTranslationsFor($language);
return $sourceTranslations->map(function ($groups, $type) use ($language, $languageTranslations) {
return $groups->map(function ($translations, $group) use ($type, $language, $languageTranslations) {
$translations = $translations->toArray();
array_walk($translations, function (&$value, $key) use ($type, $group, $language, $languageTranslations) {
$value = [
$this->sourceLanguage => $value,
$language => $languageTranslations->get($type, collect())->get($group, collect())->get($key),
];
});
return $translations;
});
});
}
@howard-mintus thanks so much
@joedixon is there a problem by don't using a reference variable here? I have the same problem
Hi @joedixon it would be very helpful if this can be merged. Im having the same issue
Had the same issue with in Laravel 9. The solution by @howard-mintus-zz worked. @joedixon please update it
@joedixon can you pls. merge this fix?
Hi @SalesFeed, this is fixed in v2.