Translate Datefield into EXTJS 6?

0

I am working in Sencha EXTJS 6 , and I have a calendar of dates called Datefield which when displayed works correctly but is in English and I would like to translate it into Spanish, but both in Sencha Architech and in the code I do not find a reference to the words except for the file that is located in ext/classic/overrides/es/ext-locale-es.js , which contains all the translations of the dates, months, days etc and the methods. I do not know if this file really has to do with datefield , or if you have to replace it, import it etc.

The datefield is this in the view file:

xtype: 'datefield',
                x: 0,
                y: 50,
                width: 320,
                fieldLabel: 'Fecha Inicio',
                name: 'date_fechaInicio',
                formatText: 'El formato de la fecha debe ser: {0}',
                invalidText: '{0} No es una fecha valida - Debe tener el siguiente formato {1}',
                format: 'd/m/Y',
                maxText: 'La fecha en este campo debe ser igual o menor a {0}',
                minText: 'La fecha en este campo debe ser igual o superior a {0}',
                submitFormat: 'd/m/Y',
                listeners: {
                    change: 'onFechaInicioChange',
                    afterrender: 'onDatefieldAfterRender'

Within the methods that affect the datefield, that I have 2 (start date and end date) are these:

 renderHora: function(value) {
    var value = new Date(value),
        hora = value.getHours(),
        minuto = (value.getMinutes() === 0)?'00':value.getMinutes();
    console.log('primer valor: '+ value);


    // if(typeof(value) == "string"){
    //     console.log('string');
    // }else{
    //     console.log('date');
    // }

    // var lo = '8:30';

    // if(typeof(lo) == "string"){
    //     console.log('string');
    // }else{
    //     console.log('date');
    // }


    //console.log("tipo dato: "+typeof(value));
    // var minuto = minuto / 60;
    // var sumando = hora + minuto;
    // console.log('suma: '+sumando);

    //var hora2 = Ext.ComponentQuery.query('[itemId=grid_jornadaLaboral]')[0].getStore().data.items[1].data.entrada_manana;


    hora = hora.toString();
    if(hora.length < 2)
    {
        hora = '0'+hora;
    }


    minuto = minuto.toString();
    if(minuto.length < 2)
    {
        minuto = '0'+minuto;
    }

    //      console.log(hora +':'+minuto);
    return(hora +':'+minuto);


},

onFechaInicioChange: function(field, newValue, oldValue, eOpts) {
    var fecha_inicio = field.getValue();

    Ext.ComponentQuery.query('datefield[name=date_fechaFin]')[0].setMinValue(fecha_inicio);


},

onDatefieldAfterRender: function(component, eOpts) {
    Ext.Ajax.request({
        url: 'json/vigencia.php',
        params:
        {
            combo:'fecha_actual'
        },

        success: function(response, opts)
        {
            var obj = Ext.decode(response.responseText);
            var fecha_actual = obj.root[0].fecha_actual;
            inicio_mes = new Date(fecha_actual);
            inicio_mes.setDate(1);

            fin_mes = new Date(fecha_actual);
            fin_mes.setMonth(fin_mes.getMonth()+1);
            fin_mes.setDate(30);

            component.setMinValue(inicio_mes);
            component.setMaxValue(fin_mes);
        },

        failure: function(response, opts) {
            console.log('server-side failure with status code ' + response.status);
        }
    });

},

onFechaFinChange: function(field, newValue, oldValue, eOpts) {
    var fecha_fin = field.getValue();

    Ext.ComponentQuery.query('datefield[name=date_fechaInicio]')[0].setMaxValue(fecha_fin);

The code is incomplete, because what follows below is from other sections:

Meanwhile, the translation file found in the project's default folders says something like this:

Ext.onReady(function() {

if (Ext.Date) {
    Ext.Date.monthNames = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];

    Ext.Date.getShortMonthName = function(month) {
        return Ext.Date.monthNames[month].substring(0, 3);
    };

    Ext.Date.monthNumbers = {
        Ene: 0,
        Feb: 1,
        Mar: 2,
        Abr: 3,
        May: 4,
        Jun: 5,
        Jul: 6,
        Ago: 7,
        Sep: 8,
        Oct: 9,
        Nov: 10,
        Dic: 11
    };

    Ext.Date.getMonthNumber = function(name) {
        return Ext.Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
    };

    Ext.Date.dayNames = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];

    Ext.Date.getShortDayName = function(day) {
        if (day == 3) return "Mié";
        if (day == 6) return "Sáb";
        return Ext.Date.dayNames[day].substring(0, 3);
    };

    Ext.Date.formatCodes.a = "(this.getHours() < 12 ? 'a.m.' : 'p.m.')";
    Ext.Date.formatCodes.A = "(this.getHours() < 12 ? 'A.M.' : 'P.M.')";

    // This will match am or a.m.
    Ext.Date.parseCodes.a = Ext.Date.parseCodes.A = {
        g:1,
        c:"if (/(a\.?m\.?)/i.test(results[{0}])) {\n"
            + "if (!h || h == 12) { h = 0; }\n"
            + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
        s:"(A\.?M\.?|P\.?M\.?|a\.?m\.?|p\.?m\.?)",
        calcAtEnd: true
    };

    Ext.Date.parseCodes.S.s = "(?:st|nd|rd|th)";
}

if (Ext.util && Ext.util.Format) {
    Ext.apply(Ext.util.Format, {
        thousandSeparator: '.',
        decimalSeparator: ',',
        currencySign: '\u20ac',
        // Spanish Euro
        dateFormat: 'd/m/Y'
    });
}
});

So, I would like to know if there is a relationship between that configuration file with respect to the fields of datefield , or if it has to be imported, or modified manually in another side.

As I see it, every time I place the mouse on any option in the datafield I get a suggestion bubble, and those texts are in the archvi èxt-locale-en.js', but if I modify them, both the folder in English / en or British / en.gb, nothing happens.

Does anyone have any idea how to translate it?

I hope you can help me Greetings and thanks !!

    
asked by user3565613 07.06.2017 в 20:59
source

1 answer

-1

You must include it in the app.json file, in my case I have the file in resources (marked with **):

{
   "name": "ejemplo",
   "version": "1.0.0.0",
   "indexHtmlPath": "index.html",
   "classpath": "${app.dir}/app,${app.dir}/resources/",
   "overrides": [
      "overrides"
   ],
   "framework": "ext",
   "toolkit": "classic",
   "theme": "theme-neptune-f37e56b5-e8b7-422b-89db-94e0b47ec5e3",
   "requires": [
      "font-awesome",
      "sencha-charts",
      "ux"
   ],
   "fashion": {
      "inliner": {
         "enable": false
      }
   },
   "sass": {
      "namespace": "ejemplo",
      "etc": [
         "sass/etc/all.scss"
      ],
      "var": [
         "sass/var/all.scss",
         "sass/var"
      ],
      "src": [
         "sass/src"
      ]
   },
   "js": [
      {
         "path": "${framework.dir}/build/ext-all-rtl-debug.js"
      },
      {
         **"path": "resources/ext-locale-es.js",**
         "includeInBundle": true
      },
      {
         "path": "app.js",
         "bundle": true
      }
   ],
   "css": [
      {
         "path": "${build.out.css.path}",
         "bundle": true,
         "exclude": [
            "fashion"
         ]
      }
   ],
   "production": {
      "output": {
         "appCache": {
            "enable": true,
            "path": "cache.appcache"
         }
      },
      "loader": {
         "cache": "${build.timestamp}"
      },
      "cache": {
         "enable": true
      },
      "compressor": {
         "type": "yui"
      }
   },
   "testing": {},
   "development": {
      "tags": []
   },
   "bootstrap": {
      "base": "${app.dir}",
      "microloader": "bootstrap.js",
      "css": "bootstrap.css"
   },
   "output": {
      "base": "${workspace.build.dir}/${build.environment}/${app.name}",
      "appCache": {
         "enable": false
      }
   },
   "cache": {
      "enable": false,
      "deltas": true
   },
   "appCache": {
      "cache": [
         "index.html"
      ],
      "network": [
         "*"
      ],
      "fallback": []
   },
   "resources": [
      {
         "path": "resources",
         "output": "shared"
      }],
   "ignore": [
      "(^|/)CVS(/?$|/.*?$)"
   ],
   "archivePath": "archive",
   "id": "......"
}
    
answered by 18.01.2018 в 22:49