Closed pratamatama closed 4 years ago
Hey,
translatedIn()
returns all models (EducationDegree
) which have a translation in the given locale.
https://docs.astrotomic.info/laravel-translatable/package/scopes#translatedin-string-usdlocale-null
So if an EducationDegree doesn't have an English translation it won't be part of the returned collection.
If you want to retrieve all EducationDegree models and get the translated attributes in English or your fallback locale you will have to configure your fallback logic like you need it https://docs.astrotomic.info/laravel-translatable/package/fallback-locale
and set the $request->locale
as app locale app()->setLocale($request->locale)
or in the package config config(['translatable.locale' => $request->locale])
otherwise you can change the logic in Locales::current()
which is used to retrieve the current locale.
https://github.com/Astrotomic/laravel-translatable/blob/f36ddecd16616a35476f38846bf41c9597b56cdb/src/Translatable/Locales.php#L46-L49
Clear enough.. Thanks for clarifying out! Closing the issue now.
I'm using
EducationDegree::translatedIn($request->locale)->get();
to get translation data, but it does not returns the fallback translation.In this case,
$request->locale
were set toUS
which is not available yet at a time. I'm expecting it to return the results translated inEN
but instead, I got an empty array.