KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Localization of DateRangePicker andTable #265

Open Victor Garcia opened this topic on on Apr 27, 2018 - 3 comments

Victor Garcia commented on Apr 27, 2018

Hi Team,

I was wondering how can I define the language to be used in the DateRangePicker and Table?

Thanks in advance

PS: KoolReport Pro is fantastic

KoolReport commented on Apr 27, 2018

Hi Victor,

First off, thank you so much for being our customer and your early tips as well :)

For your question, to create new language for widget, you create a new language file in language folder located in widget folder.

For example for Table widget, you can find the language in folder "\koolreport\widgets\koolphp\languages". There you will find our first English folder name Table.en.js, to create a new language, you just need to copy this file and save with new name, for example Table.es.json. There in new file, you should enter new translation in Espanol.

For DateRangePicker, you may find the folder "koolreport\package\inputs\language" (please help us to change folder name to "languages" with "s" at the end). This is our new discover. Then you do the same thing like above Table.

One rule: The language file always name {WidgetName}.{locale}.json and located in folder "languages" in same level with the widget.

Victor Garcia commented on Apr 27, 2018

Thanks for your quick answer!

I was able to change the language of the Table.

Regarding the DateRangePicker, using the language file (DateRangePicker.es.json in my case), I was able to change the names of the days of the week, months, and button labels. One thing I couldn't change is the labels of the ranges ("Today", "Yesterday", etc)

I've modified the DateRangePicker.es.json file, adding the following lines:

"rangesNames": [
        "Hoy",
        "Ayer",
        "Últimos 7 días",
        "Últimos 30 días",
        "Este mes",
        "Último mes"
    ],

And then the DateRangePicker.php file:

$this->rangesNames = Utility::get($this->locale,"rangesNames");

        $this->ranges = Utility::get($this->params,"ranges",array(
            $this->rangesNames[0]=>DateRangePicker::today(),
            $this->rangesNames[1]=>DateRangePicker::yesterday(),
            $this->rangesNames[2]=>DateRangePicker::last7days(),
            $this->rangesNames[3]=>DateRangePicker::last30days(),
            $this->rangesNames[4]=>DateRangePicker::thisMonth(),
            $this->rangesNames[5]=>DateRangePicker::lastMonth(),
        ));

But I really don't want to alter those files. Is there any other way to accomplish what I want?, setting some property?

Thanks!

KoolReport commented on Apr 28, 2018

Currently to add the custom ranges with custom language, you do this:

DateRangePicker::create(array(
    ...
    "ranges"=>array(
        "Hoy"=>DateRangePicker::today(),
        "Ayer"=>DateRangePicker::yesterday(),
        ...
    )
))

I think I will send your post to dev.team to have idea to improve the locale of DateRangePicker.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None