nnjeim / world

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
MIT License
748 stars 105 forks source link

add middleware details in readme #8

Closed Ivanshamir closed 2 years ago

Ivanshamir commented 2 years ago

In here, I have added the details about middleware. The locale.set middleware will help the issue.

nnjeim commented 2 years ago

@Ivanshamir Hi thank you for you contribution, i just wanted to clarify with you that all the routes are affected by the middleware by default. (see the photo here below). The middleware itself validates if the accept-locale is available in the request header and merge it in to request class. Else it will be defaulted to 'en'. Maybe you would like to explain this more in an explicit way? Thank you. Screenshot 2021-11-18 at 17 48 30

Ivanshamir commented 2 years ago

Hello, thank you for quick response. Actually as the locale is supported by only specific routes, so anyone is willing to use just Facade/World Helper Class in any route he/she can use locale by the locale.set middleware. Please correct me if I am wrong/not understanding properly. Thank you.

nnjeim commented 2 years ago

@Ivanshamir Hi again, you are totally right, when calling the helper actions, you might set the locale as App::setLocale($locale); in that case would you consider having a helper to do this? In the sense : World::setLocale('zh')->countries(); ??? if you like this would you modify your PR to do this and document it? thank you in advance.

Ivanshamir commented 2 years ago

Ok sure, I will update the PR and document it. Please give me some time. Thank you.

Ivanshamir commented 2 years ago

Hello @nnjeim I have updated the PR. Please check and let me if there is any issue. Thank you.

nnjeim commented 2 years ago

@Ivanshamir Thank you for this amazing contribution! All the best.