lesterchan / wp-useronline

Enable you to display how many users are online on your WordPress blog with detailed statistics.
https://wordpress.org/plugins/wp-useronline/
36 stars 18 forks source link

There is no way to make Useronline Templates multilingual. #45

Closed cjuroz closed 1 year ago

cjuroz commented 3 years ago

For example, whenever users_online() is called, it will use string stored in User(s) Online template (Settings > UserOnline). It would be great if text there could be load from po/mo files instead enabling multiple languages.

cjuroz commented 1 year ago

Add to functions.php :

// polylang missing string translates for other plugins/themes
add_action('init', function() {
  // wp-useronline missing strings
  pll_register_string('template-useronline', '<a href="%PAGE_URL%"><strong>%USERS%</strong> Online</a>', 'plugins/wp-useronline');
  pll_register_string('naming-user', '1 User', 'plugins/wp-useronline');
  pll_register_string('naming-user', '%COUNT% Users', 'plugins/wp-useronline');
});

Add pll__() to https://github.com/lesterchan/wp-useronline/blob/master/template-tags.php#L9 and https://github.com/lesterchan/wp-useronline/blob/master/template-tags.php#L261

$template = pll__(UserOnline_Core::$options->templates['useronline']);