How to translate jqGrid to 'en-br'?

3

I downloaded jqGrid from version 4.8.2 and tried to change the language from 'en' to 'en' always displayed the message 'undefined'. I copied the file with the information to 'en' and changed all the texts to 'en-br'. Below is the entire contents of the file to correct the problem and not have to do all the work I had.

I may have done something wrong in the jqGrid settings. Anyway, after this action worked.

File: grid.locale-en-br.js

(function( factory ) {
    "use strict";
    if ( typeof define === "function" && define.amd ) {
        // AMD. Register as an anonymous module.
        define([
            "jquery",
            "../grid.base"
        ], factory );
    } else {
        // Browser globals
        factory( jQuery );
    }
}(function( $ ) {

$.jgrid = $.jgrid || {};
if(!$.jgrid.hasOwnProperty("regional")) {
    $.jgrid.regional = [];
}
$.jgrid.regional["pt-br"] = {
    defaults : {
        recordtext: "Ver {0} - {1} de {2}",
        emptyrecords: "Nenhum registro",
        loadtext: "Carregando...",
        savetext: "Salvando...",
        pgtext : "Página {0} of {1}",
        pgfirst : "Primeira Página",
        pglast : "Última Página",
        pgnext : "Próxima Página",
        pgprev : "Página Anterior",
        pgrecs : "Registros por Página",
        showhide: "Mostrar/Ocultar Grid"
    },
    search : {
        caption: "Search...",
        Find: "Find",
        Reset: "Reset",
        odata: [{ oper:'eq', text:"igual"},{ oper:'ne', text:"diferente"},{ oper:'lt', text:"menor"},{ oper:'le', text:"menor ou igual"},{ oper:'gt', text:"maior"},{ oper:'ge', text:"maior ou igual"},{ oper:'bw', text:"inicia com"},{ oper:'bn', text:"não inicia com"},{ oper:'in', text:"está em"},{ oper:'ni', text:"não está em"},{ oper:'ew', text:"termina com"},{ oper:'en', text:"não termina com"},{ oper:'cn', text:"contém"},{ oper:'nc', text:"não contém"},{ oper:'nu', text:"nulo"},{ oper:'nn', text:"não nulo"}],
        groupOps: [ { op: "AND", text: "todos" },{ op: "OR",  text: "qualquer um" } ],
        operandTitle : "Clique para escolher a operação de pesquisa.",
        resetTitle : "Limpar valor de pesquisa"
    },
    edit : {
        addCaption: "Adicionar Registro",
        editCaption: "Editar Registro",
        bSubmit: "Enviar",
        bCancel: "Cancelar",
        bClose: "Fechar",
        saveData: "Registro modificado! Salvar mudança?",
        bYes : "Sim",
        bNo : "Não",
        bExit : "Cancelar",
        msg: {
            required:"Campo obrigatório",
            number:"Por favor, informe um número válido",
            minValue:"valor deve ser igual ou maior que ",
            maxValue:"valor deve ser menor ou igual a",
            email: "este e-mail não é válido",
            integer: "Por favor, informe um valor inteiro",
            date: "Por favor, informe uma data válida",
            url: "não é uma URL válida. Prefixo obrigatório ('http://' or 'https://')",
            nodefined : " não está definido!",
            novalue : " um valor de retorno é obrigatório!",
            customarray : "Função customizada deve retornar um array!",
            customfcheck : "Função customizada deve estar presente em caso de validação customizada!"

        }
    },
    view : {
        caption: "Ver Registro",
        bClose: "Fechar"
    },
    del : {
        caption: "Deletar",
        msg: "Deletar registro(s) selecionado(s)?",
        bSubmit: "Deletar",
        bCancel: "Cancelar"
    },
    nav : {
        edittext: "",
        edittitle: "Editar linha selecionada",
        addtext:"",
        addtitle: "Adicionar nova linha",
        deltext: "",
        deltitle: "Deletar linha selecionada",
        searchtext: "",
        searchtitle: "Procurar registros",
        refreshtext: "",
        refreshtitle: "Recarregar Grid",
        alertcap: "Aviso",
        alerttext: "Por favor, selecione um linha",
        viewtext: "",
        viewtitle: "Ver linha selecionada",
        savetext: "",
        savetitle: "Salvar linha",
        canceltext: "",
        canceltitle : "Cancelar edição da linha"
    },
    col : {
        caption: "Mostrar/Esconder Colunas",
        bSubmit: "Enviar",
        bCancel: "Cancelar"
    },
    errors : {
        errcap : "Erro",
        nourl : "Nenhuma URL definida",
        norecords: "Sem registros para exibir",
        model : "Comprimento de colNames <> colModel!"
    },
    formatter : {
        integer : {thousandsSeparator: ",", defaultValue: '0'},
        number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'},
        currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
        date : {
            dayNames:   [
                            "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb",
                            "Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"
                        ],
                        monthNames: [
                            "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez",
                            "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
                        ],
                        AmPm : ["am","pm","AM","PM"],
            S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
            srcformat: 'Y-m-d',
            newformat: 'n/j/Y',
            parseRe : /[#%\\/:_;.,\t\s-]/,
            masks : {
                // see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
                // and see http://docs.jquery.com/UI/Datepicker/formatDate
                // and https://github.com/jquery/globalize#dates for alternative formats used frequently
                // one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many
                // information about date, time, numbers and currency formats used in different countries
                // one should just convert the information in PHP format
                ISO8601Long:"Y-m-d H:i:s",
                ISO8601Short:"Y-m-d",
                // short date:
                //    n - Numeric representation of a month, without leading zeros
                //    j - Day of the month without leading zeros
                //    Y - A full numeric representation of a year, 4 digits
                // example: 3/1/2012 which means 1 March 2012
                ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy"
                // long date:
                //    l - A full textual representation of the day of the week
                //    F - A full textual representation of a month
                //    d - Day of the month, 2 digits with leading zeros
                //    Y - A full numeric representation of a year, 4 digits
                LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy"
                // long date with long time:
                //    l - A full textual representation of the day of the week
                //    F - A full textual representation of a month
                //    d - Day of the month, 2 digits with leading zeros
                //    Y - A full numeric representation of a year, 4 digits
                //    g - 12-hour format of an hour without leading zeros
                //    i - Minutes with leading zeros
                //    s - Seconds, with leading zeros
                //    A - Uppercase Ante meridiem and Post meridiem (AM or PM)
                FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt"
                // month day:
                //    F - A full textual representation of a month
                //    d - Day of the month, 2 digits with leading zeros
                MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd"
                // short time (without seconds)
                //    g - 12-hour format of an hour without leading zeros
                //    i - Minutes with leading zeros
                //    A - Uppercase Ante meridiem and Post meridiem (AM or PM)
                ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt"
                // long time (with seconds)
                //    g - 12-hour format of an hour without leading zeros
                //    i - Minutes with leading zeros
                //    s - Seconds, with leading zeros
                //    A - Uppercase Ante meridiem and Post meridiem (AM or PM)
                LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt"
                SortableDateTime: "Y-m-d\TH:i:s",
                UniversalSortableDateTime: "Y-m-d H:i:sO",
                // month with year
                //    Y - A full numeric representation of a year, 4 digits
                //    F - A full textual representation of a month
                YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy"
            },
            reformatAfterEdit : false,
            userLocalTime : false
        },
        baseLinkUrl: '',
        showAction: '',
        target: '',
        checkbox : {disabled:true},
        idName : 'id'
    }
};
}));
    
asked by anonymous 31.05.2015 / 15:38

1 answer

2

I downloaded jqGrid from version 4.8.2 and tried to change the language from 'en' to 'en' always displayed the message 'undefined'. I copied the file with the information to 'en' and changed all the texts to 'en-br'. Below is the entire contents of the file to correct the problem and not have to do all the work I had.

I may have done something wrong in the jqGrid settings. Anyway, after this action worked.

File: grid.locale-en-br.js

(function( factory ) {
    "use strict";
    if ( typeof define === "function" && define.amd ) {
        // AMD. Register as an anonymous module.
        define([
            "jquery",
            "../grid.base"
        ], factory );
    } else {
        // Browser globals
        factory( jQuery );
    }
}(function( $ ) {

$.jgrid = $.jgrid || {};
if(!$.jgrid.hasOwnProperty("regional")) {
    $.jgrid.regional = [];
}
$.jgrid.regional["pt-br"] = {
    defaults : {
        recordtext: "Ver {0} - {1} de {2}",
        emptyrecords: "Nenhum registro",
        loadtext: "Carregando...",
        savetext: "Salvando...",
        pgtext : "Página {0} of {1}",
        pgfirst : "Primeira Página",
        pglast : "Última Página",
        pgnext : "Próxima Página",
        pgprev : "Página Anterior",
        pgrecs : "Registros por Página",
        showhide: "Mostrar/Ocultar Grid"
    },
    search : {
        caption: "Search...",
        Find: "Find",
        Reset: "Reset",
        odata: [{ oper:'eq', text:"igual"},{ oper:'ne', text:"diferente"},{ oper:'lt', text:"menor"},{ oper:'le', text:"menor ou igual"},{ oper:'gt', text:"maior"},{ oper:'ge', text:"maior ou igual"},{ oper:'bw', text:"inicia com"},{ oper:'bn', text:"não inicia com"},{ oper:'in', text:"está em"},{ oper:'ni', text:"não está em"},{ oper:'ew', text:"termina com"},{ oper:'en', text:"não termina com"},{ oper:'cn', text:"contém"},{ oper:'nc', text:"não contém"},{ oper:'nu', text:"nulo"},{ oper:'nn', text:"não nulo"}],
        groupOps: [ { op: "AND", text: "todos" },{ op: "OR",  text: "qualquer um" } ],
        operandTitle : "Clique para escolher a operação de pesquisa.",
        resetTitle : "Limpar valor de pesquisa"
    },
    edit : {
        addCaption: "Adicionar Registro",
        editCaption: "Editar Registro",
        bSubmit: "Enviar",
        bCancel: "Cancelar",
        bClose: "Fechar",
        saveData: "Registro modificado! Salvar mudança?",
        bYes : "Sim",
        bNo : "Não",
        bExit : "Cancelar",
        msg: {
            required:"Campo obrigatório",
            number:"Por favor, informe um número válido",
            minValue:"valor deve ser igual ou maior que ",
            maxValue:"valor deve ser menor ou igual a",
            email: "este e-mail não é válido",
            integer: "Por favor, informe um valor inteiro",
            date: "Por favor, informe uma data válida",
            url: "não é uma URL válida. Prefixo obrigatório ('http://' or 'https://')",
            nodefined : " não está definido!",
            novalue : " um valor de retorno é obrigatório!",
            customarray : "Função customizada deve retornar um array!",
            customfcheck : "Função customizada deve estar presente em caso de validação customizada!"

        }
    },
    view : {
        caption: "Ver Registro",
        bClose: "Fechar"
    },
    del : {
        caption: "Deletar",
        msg: "Deletar registro(s) selecionado(s)?",
        bSubmit: "Deletar",
        bCancel: "Cancelar"
    },
    nav : {
        edittext: "",
        edittitle: "Editar linha selecionada",
        addtext:"",
        addtitle: "Adicionar nova linha",
        deltext: "",
        deltitle: "Deletar linha selecionada",
        searchtext: "",
        searchtitle: "Procurar registros",
        refreshtext: "",
        refreshtitle: "Recarregar Grid",
        alertcap: "Aviso",
        alerttext: "Por favor, selecione um linha",
        viewtext: "",
        viewtitle: "Ver linha selecionada",
        savetext: "",
        savetitle: "Salvar linha",
        canceltext: "",
        canceltitle : "Cancelar edição da linha"
    },
    col : {
        caption: "Mostrar/Esconder Colunas",
        bSubmit: "Enviar",
        bCancel: "Cancelar"
    },
    errors : {
        errcap : "Erro",
        nourl : "Nenhuma URL definida",
        norecords: "Sem registros para exibir",
        model : "Comprimento de colNames <> colModel!"
    },
    formatter : {
        integer : {thousandsSeparator: ",", defaultValue: '0'},
        number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'},
        currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
        date : {
            dayNames:   [
                            "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb",
                            "Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"
                        ],
                        monthNames: [
                            "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez",
                            "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
                        ],
                        AmPm : ["am","pm","AM","PM"],
            S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
            srcformat: 'Y-m-d',
            newformat: 'n/j/Y',
            parseRe : /[#%\\/:_;.,\t\s-]/,
            masks : {
                // see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
                // and see http://docs.jquery.com/UI/Datepicker/formatDate
                // and https://github.com/jquery/globalize#dates for alternative formats used frequently
                // one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many
                // information about date, time, numbers and currency formats used in different countries
                // one should just convert the information in PHP format
                ISO8601Long:"Y-m-d H:i:s",
                ISO8601Short:"Y-m-d",
                // short date:
                //    n - Numeric representation of a month, without leading zeros
                //    j - Day of the month without leading zeros
                //    Y - A full numeric representation of a year, 4 digits
                // example: 3/1/2012 which means 1 March 2012
                ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy"
                // long date:
                //    l - A full textual representation of the day of the week
                //    F - A full textual representation of a month
                //    d - Day of the month, 2 digits with leading zeros
                //    Y - A full numeric representation of a year, 4 digits
                LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy"
                // long date with long time:
                //    l - A full textual representation of the day of the week
                //    F - A full textual representation of a month
                //    d - Day of the month, 2 digits with leading zeros
                //    Y - A full numeric representation of a year, 4 digits
                //    g - 12-hour format of an hour without leading zeros
                //    i - Minutes with leading zeros
                //    s - Seconds, with leading zeros
                //    A - Uppercase Ante meridiem and Post meridiem (AM or PM)
                FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt"
                // month day:
                //    F - A full textual representation of a month
                //    d - Day of the month, 2 digits with leading zeros
                MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd"
                // short time (without seconds)
                //    g - 12-hour format of an hour without leading zeros
                //    i - Minutes with leading zeros
                //    A - Uppercase Ante meridiem and Post meridiem (AM or PM)
                ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt"
                // long time (with seconds)
                //    g - 12-hour format of an hour without leading zeros
                //    i - Minutes with leading zeros
                //    s - Seconds, with leading zeros
                //    A - Uppercase Ante meridiem and Post meridiem (AM or PM)
                LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt"
                SortableDateTime: "Y-m-d\TH:i:s",
                UniversalSortableDateTime: "Y-m-d H:i:sO",
                // month with year
                //    Y - A full numeric representation of a year, 4 digits
                //    F - A full textual representation of a month
                YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy"
            },
            reformatAfterEdit : false,
            userLocalTime : false
        },
        baseLinkUrl: '',
        showAction: '',
        target: '',
        checkbox : {disabled:true},
        idName : 'id'
    }
};
}));
    
02.06.2015 / 19:10