mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido coger el idioma
This commit is contained in:
@ -776,6 +776,15 @@ $routes->group('api', ['filter' => 'jwt'], static function ($routes) {
|
||||
// ...
|
||||
});
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Translation
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
$routes->group('translate', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||
$routes->post('getTranslation', 'Language::getTranslation', ['as' => 'getKeys']);
|
||||
});
|
||||
$routes->resource('translate', ['namespace' => 'App\Controllers', 'controller' => 'Language', 'except' => '']);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -15,4 +15,15 @@ class Language extends BaseController
|
||||
$url = previous_url();
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
|
||||
// Function to get the translation of the language file from a AJAX request
|
||||
public function getTranslation()
|
||||
{
|
||||
$translationFile = $this->request->getPost('translationFile');
|
||||
$locale = $this->request->getPost('locale');
|
||||
$path = "Language/{$locale}/$translationFile.php";
|
||||
$lang = require APPPATH.$path;
|
||||
return json_encode($lang);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,12 +31,12 @@ return [
|
||||
'presupuestoEstadoAceptado' => 'Acepted',
|
||||
'incidencia' => 'Incident',
|
||||
'reimpresion' => 'Reprint',
|
||||
'reimpresion' => 'Free of charge',
|
||||
'autor' => 'Author',
|
||||
'coleccion' => 'Collection',
|
||||
'numeroEdicion' => 'Edition number',
|
||||
'isbn' => 'ISBN',
|
||||
'referenciaCliente' => 'Customer reference',
|
||||
'formatoLibro' => "Book format",
|
||||
'papelFormatoId' => "Size",
|
||||
'papelFormatoPersonalizado' => 'Custom size',
|
||||
'papelFormatoAncho' => 'Width',
|
||||
|
||||
@ -63,6 +63,7 @@ return [
|
||||
'isbn' => 'ISBN',
|
||||
'referenciaCliente' => 'Referencia del cliente',
|
||||
'referenciaCliente2' => 'Referencia',
|
||||
'formatoLibro' => "Formato libro",
|
||||
'papelFormatoId' => "Tamaño",
|
||||
'papelFormatoPersonalizado' => 'Tamaño personalizado',
|
||||
'papelFormatoAncho' => 'Ancho',
|
||||
|
||||
@ -20,6 +20,8 @@ $picture = "/assets/img/default-user.png";
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
|
||||
|
||||
<meta name="locale" content="<?= $session->get("lang") ?>">
|
||||
|
||||
<title><?= config('Safekat')->appName ?></title>
|
||||
|
||||
<meta name="description" content="" />
|
||||
|
||||
@ -5,7 +5,7 @@ class DatosGenerales {
|
||||
|
||||
constructor(domItem) {
|
||||
this.domItem = domItem;
|
||||
this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/menuitems', 'Seleccione formato');
|
||||
this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/menuitems', window.translations["formatoLibro"]);
|
||||
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
|
||||
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
|
||||
|
||||
|
||||
@ -1,9 +1,26 @@
|
||||
import DatosGenerales from './datosGenerales.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
function initPresupuesto(response){
|
||||
|
||||
window.translations = JSON.parse(response);
|
||||
|
||||
let datosGenerales = new DatosGenerales($("#datos-generales"));
|
||||
datosGenerales.init();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
new Ajax('/translate/getTranslation', {locale: locale, translationFile: 'Presupuestos'}, {},
|
||||
initPresupuesto,
|
||||
function(error){
|
||||
console.log("Error getting translations:", error);
|
||||
}
|
||||
).post();
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user