Replies: 1 comment
-
If you want country names in German then you need to switch your app locale to 'de' like this: App::setLocale('de'); Then the Repository::registerSource(Country::class, 'de', base_path('/vendor/squirephp/countries-de/resources/data.csv')); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Warning: might be a silly question for the more experienced developers - my apologies!
I was giving a try with this one on a private project and a compliment to the owners. Nice job!
However, I hit a problem with pulling the translated countries from the data source - do I need a relation here and if, how would that look like?
Installed with
composer require squirephp/countries-de
andcomposer require squirephp/countries-en
In my blade file I'm using:
<select name="country">
@foreach (Squire\Models\Country::orderBy('name')->get() as $country)
<option value="{{ $country->id }}">{{ $country->name }} {{ $country->flag }}</option>
@endforeach
</select>
in the Controller
Country::all()
both versions work like a charm - but how do I pull the "de" version in this example: "Squire\Models\Country::orderBy('name')->get()" - my localization works perfectly fine as well and I can get the locale anytime with app()->getLocale() which will return either "de" or "en".
Long version short: I want to use the
countries-de
data when the user accesses the website withmydomain.com/de/whatever
. Let me know if you can help me, pls.Thanks, Michael
Beta Was this translation helpful? Give feedback.
All reactions