Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Add docs for switchLocale in view #230

Closed
ntvsx193 opened this issue Dec 13, 2017 · 6 comments
Closed

Add docs for switchLocale in view #230

ntvsx193 opened this issue Dec 13, 2017 · 6 comments
Assignees

Comments

@ntvsx193
Copy link
Contributor

Issue make from https://forum.adonisjs.com/t/antl-view-with-user-locale/462/6

@thetutlage
Copy link
Member

I don't think this has to be the part of docs. The antl object is shared with view and that means all methods can be called inside view and not only switchLocale.

Also I will never never views to mutate state, this is literally the worst way to do something. One should call antl.switchLocale inside controller and then render the view.

@ntvsx193
Copy link
Contributor Author

Can you write example code for usage with switchLocale for view in controller?

@thetutlage
Copy link
Member

controllerMethod ({ antl, view }) {
  antl.switchLocale('fr')
  return view.render('some-view')
}

NOTE: The antl instance is shared with controller and the view you will render from that controller.

@ntvsx193
Copy link
Contributor Author

Wow! It is great! I think otherwise :)
I am add this to docs

@thetutlage
Copy link
Member

I will not, since one thing leads to other. If method a is documented, then why not b, which will end up in duplicated docs everywhere.

@ntvsx193
Copy link
Contributor Author

Okay, i'm found now in docs

http://adonisjs.com/docs/4.0/internationalization#_context_instance

However, you can also make use of the antl object, which is passed to all route handlers like request and response.

But it's not explicitly indicated.
See new changes from PR

thetutlage pushed a commit that referenced this issue Jan 7, 2018
* feat(config): add docs for Config.set (#227)

* feat(config): add docs for Config.set (#227)

* feat(view): add docs for antl.switchLocale in view (#230)

* feat(view): add docs for antl.switchLocale in view (#230)
@thetutlage thetutlage self-assigned this Jan 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants