cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
279 stars 83 forks source link

{date} is not translated into locale language #278

Closed zebrastribe closed 3 years ago

zebrastribe commented 3 years ago

Skærmbillede 2020-10-28 kl  14 28 40 I use the {date} tag but it does not translate into swedish (also need in danish, norwegian).

How can I translate it?

cabrerahector commented 3 years ago

Hi @zebrastribe,

If you're using the plugin version from wordpress.org then in order to translate dates you'll need to create a translation file for Danish & Norwegian as detailed here.

If you're using the GitHub version of the plugin then make sure WordPress has the language pack files for Danish and Norwegian installed in your /wp-content/languages folder for WPP to be able to translate dates. One easy way to get WordPress to automatically get these language packs for you:

  1. Go to Settings > General.
  2. Set Site Language to Danish and save changes.
  3. Go to Dashboard > Updates and click on Check Again. This will force WordPress to check for updates and detect that you need a new language pack. You should see that there are new translations available at the bottom of the page. Follow the instructions to install them on your site.
  4. When that's done, go back to step 2, set the site language to Norwegian and follow the same process as before.
  5. Finally, change your site's language back to whatever it was.
  6. Profit!

P.S.: Nice design, by the way! Would you mind if I created a widget theme inspired on it?

zebrastribe commented 3 years ago

I use the the version from the Wordpress repo. The language is set to swedish in wordpress and the timezone is stockholm. Also there is a swedish translation inside the Moment/locales/ folder. And there is also a swedish language files inside wp-content/languages/

The admin part of WPP is partly translated into swedish...

Skærmbillede 2020-10-29 kl  09 37 04

But on the site the texts is in english...

(PS. Sure you can use the design the font is Bebas neue and Roboto:) https://fonts.google.com/specimen/Bebas+Neue https://fonts.google.com/specimen/Roboto+Condensed

cabrerahector commented 3 years ago

Alright, I'll see if I can reproduce this as soon as I get some spare time. Right now I'm swamped with work T_T

I'll leave a comment after testing.

cabrerahector commented 3 years ago

Hey @zebrastribe,

So the Swedish locale file included in wp-content/plugins/wordpress-popular-posts/src/Moment/Locales seems to be misnamed. The file is currently named as _seSV.php, while WordPress uses _svSE when setting the site language to Swedish. Renaming said file as _svSE.php fixes the issue for me so give it a shot and report back.

Please keep in mind that this is just a temporary workaround: the GitHub version of the plugin no longer uses the referenced Moment library to translate dates. Once I release this version on wordpress.org this workaround will no longer work so you should follow the instructions I posted earlier to download the official language packs for Danish (Swedish?) and Norwegian so future WPP releases can translate dates properly.

zebrastribe commented 3 years ago

Great stuff. Looking forward to the update. Thank you for all your help