Showing posts with label Dashboard. Show all posts
Showing posts with label Dashboard. Show all posts

Saturday 8 June 2019

How to add Language of custom plugin in Admin dashboard in wordpress



Add text for language like this "<?php echo __('General options', 'roomle'); ?>"

Step 1 : Create plugin like "roomle"
Step 2 : Set domain path into plugin file like following screenshot

Step 3 : Create "roomle.pot" inside /wp-content/plugins/roomle/languages/
Step 4 : Add like following text inside "roomle.pot" file (FYI : Don't add any translation language just add as (msgstr = ""))
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-08 12:08+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: functions.php:29
#, php-format
msgid "Roomle"
msgstr ""
#: functions.php:47
#, php-format
msgid "Select"
msgstr ""
#: functions.php:56
msgid "Roomle product type"
msgstr ""
Step 5 : Download the free plugin called Loco Translate from here. Or add directly from the WordPress administration via Plugins > Add New. (https://wordpress.org/plugins/loco-translate/)
Step 6 : Install and Activate Loco plugin
Step 7 : Click on Plugin inner menu of Loco after that click into your plugin from list.

Step 8 : Click on New language
Step 9 : Choose a language which you wish to translate (Here translate from English to Spanish)

Step 10 : See Source text (its from "roomle.pot" ) you need to add text of translate language.

Step 11 : After create all text to Spanish language, Check "/roomle/wp-content/languages/plugins/" directory. your 2 file is created here like "roomle-es_ES.mo" and "roomle-es_ES.po"
Step 12 : If you wish to check so you need to download wordpress in spanish language and setup wordpress and check

Also this answer for following question

  • How to Change the Admin plugin Language
  • How to add language into your plugin
  • How to add language into your custom plugin

Monday 11 April 2016

Today's/Month sales report on admin dashboard in magento

The sales report is one of the main progress indicators in e-commerce. We often create a sales report using the default Magento features – just go to Reports -> Sales -> Orders, and then, fill in the filter form on that page. This way allows us to get full information about sales on the web store.

Nevertheless, getting back to all these actions every time is not handy, especially if we do not need the full report. So, let’s find out how to display the reports in different parts in the admin panel.

First of all, we add a part of the code that will display our report on the dashboard in the admin panel – so, to do this place the following code snippet to
[Magento root]/app/design/adminhtml/default/default/template/dashboard/index.phtml:

<div class="entry-edit cmsdas-1 todaysale">
                <div class="cms-entry-edit-head">
                <div class="lifetime-sales"><?php echo "Today's sales"  ?></div>
                    <div class="cms-va">
                        <span class="price"><?php echo Mage::helper('NAMESPACE_MODULE/todaysale')->getTotals();?></span>
                    <span style="font-size:14px; color:#686868;">
                    </span>
                    </div>
                </div>
            </div>
In this code snippet we have a standard markup and use custom helper Mage::helper('NAMESPACE_MODULE/todaysale')->getTotals(). In this case, the helper returns an information about the report.

Pay attention to the code helper which generates information about the report. Here are several methods that build the report.

class NAMESPACE_MODULE_Helper_Todaysale extends Mage_Core_Helper_Abstract {
    public function getTotals() {
       
        $isFilter= '';
        $todaysales = Mage::getResourceModel('reports/order_collection')
            ->calculateSales($isFilter);
        $todayStartOfDayDate  = Mage::app()->getLocale()->date()
            ->setTime('00:00:00')
            ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        //$todayStartOfDayDate ='2016-04-7 00:00:00';
        $todayEndOfDayDate  = Mage::app()->getLocale()->date()
            ->setTime('23:59:59')
            ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
       
        $todaysales->addAttributeToFilter('created_at', array(
            'from'  => $todayStartOfDayDate,
            'to'    =>  $todayEndOfDayDate,                  
        ));
        $todaysales->load();
        $todaysale = $todaysales->getFirstItem();
        //$this->addTotal($this->__("Today's Sales"), $todaysale->getLifetime());
        return (string)Mage::helper('core')->currency($todaysale->getLifetime(), true, false);
    }
}