lefnire/habitrpg — pull request #921 by switz (2013-05-09 17:17:53+00:00)
Title: @slappybag => Allow locale to be set from a model middleware

So instead of futzing around with URLs, I sent a pull request to `derby-i18n` to enable setting a user's locale from a derby model via an express middleware. If that sounds confusing, it's not - I'll show you:

I gave you an example middleware in `src/server/middleware.coffee`
```coffeescript
translate = (req, res, next) ->
model = req.getModel()

# Set locale to bg on dev
model.set '_i18n.locale', 'bg' if process.env.NODE_ENV is "development"

next()
```

For now, I've pinned `derby-i18n` to `switz#master`, but I've sent over a pull request here: https://github.com/jamesknelson/derby-i18n/pull/9

So, I think we should either attach the user object to the session `req.session.user` or somehow attach the language to the session. It will also try to check headers first and see if it can figure out where the person is coming from. If someone from another country wants to test this out once it hits beta.habitrpg.com I'd appreciate it. I have no idea if it will work.

@slappybag If you have any questions, hit me up in IRC.