Translate month name in WordPress

In WordPress, you might want to rename posts’ month name from English to Dhivehi or whatever language. This is a very simple function which will help you change the posts’ month name.

Put this into your function.php

function mas($month) {
switch ($month) {
case 1:
    $mas = "ޖަނަވަރީ";
    break;
case 2:
    $mas = "ފެބުރުވަރީ";
    break;
case 3:
    $mas = "މާރިޗު";
    break;
case 4:
    $mas = "އެޕްރީލް";
    break;
case 5:
    $mas = "މެއި";
    break;
case 6:
    $mas = "ޖޫން";
    break;
case 7:
    $mas = "ޖުލައި";
    break;
case 8:
    $mas = "އޯގަސްޓު";
    break;
case 9:
    $mas = "ސެޕްޓެންބަރު";
    break;
case 10:
    $mas = "އޮކްޓޯބަރު";
    break;
case 11:
    $mas = "ނޮވެންބަރު";
    break;
case 12:
    $mas = "ޑިސެންބަރު";
    break;
}
return($mas); }

 

And use this wherever you want to view the date in Dhivehi.

<?php echo mas(get_the_date('n')); ?>