public function move($id, $direction)
    {
        $this->loadModel('Locale.Languages');
        $language = $this->Languages->get($id);
        $unordered = $this->Languages->find()
            ->select(['id', 'ordering'])
            ->order(['ordering' => 'ASC'])
            ->all()
            ->extract('id')
            ->toArray();

        $position = array_search($language->id, $unordered);
        if (!is_integer($position)) {
            $this->redirect($this->referer());
        }

        $direction = $direction === 'up' ? 'down' : 'up'; // fix orientation, top-down to left-right
        $ordered = array_move($unordered, $position, $direction);
        if (md5(serialize($ordered)) != md5(serialize($unordered))) {
            foreach ($ordered as $ordering => $id) {
                $this->Languages->updateAll(compact('ordering'), compact('id'));
            }
        }

        $this->title(__d('locale', 'Reorder Language'));
        $this->Flash->success(__d('locale', 'Language successfully reordered!'));
        $this->redirect($this->referer());
    }