<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Lang;

class I18NextTranslations extends Controller {
	/**
	 * Returns the translation object for i18next plugin
	 * for a given namespace and language.
	 * - language: corresponds to folders in "resources/lang"
	 * - namespace: corresponds to filename in such folder
	 *
	 * @return \Illuminate\Http\Response
	 */
	public function index(Request $request) {
		$language = $request->input('lng');
		$namespace = $request->input('ns');
		$array = Lang::get($namespace, [], $language);
		return response()->json($array);
	}

}
