Skip to content

Translating "Days Ago" via %s Variable and Setting Correct WordPress Site Language

The "3 hours ago" text on your ads comes from two places at once: the Listivo Panel and WordPress itself. This article shows you how to translate both halves, so the elapsed time reads correctly in your language.

1 minute read

This article focuses on how to translate texts in your single ads template, blog posts, quick view, and many other modules that show the time elapsed since a particular post or ad was added to your website.

Single ad page for the "Wallie toy" listing, with the "2 years ago" timestamp next to the 1082 Views counter marked out.

This text function is based on default WordPress functionality, and as theme authors, we do not duplicate functions that already exist. This text can appear in various forms, displaying when an ad was added, for example:

  • 3 hours ago
  • 6 days ago
  • 3 months ago
  • 2 years ago

Translate the "%s ago" string

Visit Listivo Panel > Translate & Rename and search for the %s ago text string. %s is a variable that represents a number followed by a time period (e.g., 3 hours, 3 days, 3 months, 3 years), and you can place it anywhere in the text to adapt it to your language. You can add text before and after it, as shown below.

Translate & Rename in the Listivo Panel, Strings tab, with the "%s ago" row filled in as "text before %s text after" and the Save Changes button marked.

The configuration as above will result in displaying dates like this:

The listing header now reading "text before 2 years text after" where the date used to be, next to 1075 Views.

Set the correct WordPress site language

"2 years" comes from WordPress, not from Listivo
Text such as "2 years" (or months, days, hours) cannot be translated in Listivo Panel > Translate & Rename, because it comes directly from the WordPress site translation. If you use Spanish, for example, make sure your website's Site Language is set to Spanish in wp-admin > Settings > General.
WordPress Settings > General with the Site Language dropdown set to Español.

This will automatically translate all "years," "months," etc., text strings to your language.

The listing header reading "text before 2 años text after", with "2 años" marked out.

Ask the people who build Listivo

We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.

Was this guide helpful?