• Resolved Balázs Páti

    (@rvr909303)


    I’m trying to translate the months for a website of a client and I can’t find any way to make it work.

    I’m using this shortcode in a basic text widget for a sidebar:

    [wpp header=’?????? ?????’ cat=’3,4,5′ post_type=’post’ cat=’786,787,788,789′ limit=5 range=’last30days’ order_by=’views’ freshness=’1′ stats_date=1 stats_date_format=’j F, Y’ thumbnail_width=100 thumbnail_height=75 post_html=’

    • <div class=”custom-post-list-mostviewed-thumb”>{thumb}</div>
      <div class=”custom-post-list-mostviewed-details”>

      {title}
      <div class=”wpp-stats”>{date}</div>
      </div>

    ‘]

    This is the date format: j F, Y

    Since the date format displays the months in fully written form, I need a way to show the months in Arabic, but they keep showing up in English.

    Site language is set to Arabic in WordPress General Options on /wp-admin/options-general.php.

    Tried multiple ways of doing it with str_ireplace, but the Month names are always in English instead of Arabic.

    Please help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @rvr909303,

    Try creating a locale file for your language in wp-content/plugins/wordpress-popular-posts/src/Moment/Locales. You can find a list of available locales to copy from here.

    • This reply was modified 4 years, 10 months ago by Hector Cabrera. Reason: Corrected path to locale files
    Thread Starter Balázs Páti

    (@rvr909303)

    The website is for an NGO raising funds for Syria.
    It has WordPress 5.3.2–ar installed.

    I have set the server’s locale (running Fedora 28) to ar_SY (Arabic/Syrian) using these commands, then restarted the webserver.

    sudo dnf install glibc-langpack-ar
    sudo localectl set-locale LANG=ar_SY.utf8

    upon checking localctl it returns this:
    System Locale: LANG=ar_SY.utf8
    VC Keymap: us
    X11 Layout: n

    _______

    So the server’s locale is Arabic/Syrian

    I’ve specified the WordPress language in Settings >> General to the default arabic (ar)

    _______

    I created ar_SY.php file, but I’m not sure what to do next.

    The months are still in English, even though the locale on the server level is ar_SY, and the WordPress language is set to Arabic and the ar_SY.php file with the Arabic month text present in src/Moment/Locales.

    What am I doing wrong?

    I found this link showing the Arabic translation is 1% complete for the plugin.
    https://translate.www.ads-software.com/locale/ar/default/wp-plugins/wordpress-popular-posts/

    Please get back to me about this, this should be so simple & I’ve wasted a ton of time to no avail.

    • This reply was modified 4 years, 10 months ago by Balázs Páti.
    • This reply was modified 4 years, 10 months ago by Balázs Páti.
    Plugin Author Hector Cabrera

    (@hcabrera)

    Please share the file you created (upload it somewhere, like pastebin.com) and I’ll give it a try as soon as I can.

    Thread Starter Balázs Páti

    (@rvr909303)

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey there!

    Finally had a chance to give this a try and the problem was the filename you used when you created the locale file.

    When you install WordPress 5.3.2–ar (or if you switch the language to arabic via the Settings page) the locale WordPress uses is ar, not ar_SY.

    Name your locale file as ar.php and it’ll work.

    Thread Starter Balázs Páti

    (@rvr909303)

    Hi Héctor!

    Yes, the issue was the file naming convention, not the contents of the .php file.

    The month names are now in Arabic.

    Thank you for looking into it! ?? ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Translate months in widget’ is closed to new replies.