rstaib / jquery-bootgrid

Nice, sleek and intuitive. A grid control especially designed for bootstrap.
http://www.jquery-bootgrid.com
MIT License
972 stars 364 forks source link

add i18n support #20

Open JLHwung opened 10 years ago

JLHwung commented 10 years ago

It seems that bootgrid lacks the i18n support, at least on first glance. Currently the labels variable contains all the strings that need to be localized.

A sample of zh-CN localization (it works on 1.0.0) might be as follows:

(function ($) {
    "use strict";

    $.extend($.fn.bootgrid.Constructor.defaults.labels, {
        all: "全部",
        infos: "共{{ctx.total}}条记录,本页为{{ctx.start}}—{{ctx.end}}条记录",
        loading: "载入中……",
        noResults: "找不到记录!",
        refresh: "刷新",
        search: "搜索"
    });
})(jQuery);

I don't make pull request because one might need some extra designs on the code structure when formally taking locale into consideration. I will be grateful if bootgrid can add formal i18n support.

johnnyxlemonade commented 8 years ago

Easy hack.. For demo purpose.. Two variants 1) Modify core bootgrid template (dont pls, you know ) 2) make custom template (right way)

My solution -translate all - headers of table + default lang Custom template

templates: {  headerCell:   ...code... <a ...codedefault... data-i18n="grid.header.{{ctx.column.id}}">...code_default...

Using ajax - read docs, how parse & sending data (request...) Static table - i18n

lng.json "grid":{   "header":{    "col":{     "id": "ID"    }   }  }

I am using i18next.com