Please or Register to create posts and topics.

Change specific translated strings

The following code contains some examples on how to change specific translated strings to a custom one without creating/changing a complete translation file. The modified strings will not affect similar strings generated by other plugins.

As usual you have to add this code to your themes functions.php file.

add_filter('ngettext', 'change_ntranslations', 20, 5);
add_filter('gettext', 'change_translations', 20, 3);

function change_translations($translated_text, $untranslated_text, $domain) {
  if ($domain === 'asgaros-forum') {
    switch ($translated_text) {
      case 'Forum':
        $translated_text = 'My Board';
      break;
      case '%s Topics':
        $translated_text = '%s Threads';
      break;
      case '%s Topic':
        $translated_text = '%s Thread';
      break;
      case 'Last post':
        $translated_text = '';
      break;
    }
  }

  return $translated_text;
}

function change_ntranslations($translated_text, $single, $plural, $number, $domain) {
  if ($domain === 'asgaros-forum') {
    $translated_text = change_translations($translated_text, '', 'asgaros-forum');
  }

  return $translated_text;
}

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hello Asgaros,

I´m just exploring the plugin´s characteristics before installation. Is there a way to apply these translations to a specific forum among others? Maybe using its shortcode to assign the translation specifically to it?

Julia

Quote from Deleted user on September 11, 2021, 2:38 am

Hello Asgaros,

I´m just exploring the plugin´s characteristics before installation. Is there a way to apply these translations to a specific forum among others? Maybe using its shortcode to assign the translation specifically to it?

Julia

It offers a translation management system and translation feature that helps you to create your desired language option on your website.

mapquest driving directions smash karts

Quote from Deleted user on September 11, 2021, 2:38 am

Hello Asgaros,

I´m just exploring the plugin´s characteristics before installation. Is there a way to apply these translations to a specific forum among others? Maybe using its shortcode to assign the translation specifically to it?

Julia

Before I install the plugin, I’m merely going through its features and looking at their documentation. Is there a method to apply these translations to a particular topic in addition to the ones that are available? Perhaps you could assign the translation particularly to it by utilizing the shortcode for it.

backrooms is a fun escape room game.

Citazione da Asgaros il luglio 22, 2017, 3:32 pm

Il codice seguente contiene alcuni esempi su come modificare stringhe tradotte specifiche in una personalizzata senza creare/modificare un file di traduzione completo. Le stringhe modificate non influiranno su stringhe simili generate da altri plugin.

Come al solito devi aggiungere questo codice al tuo file di funzioni tematiche.php.

add_filter('ngettext', 'change_ntranslations', 20, 5);
add_filter('gettext', 'change_translations', 20, 3);

function change_translations($translated_text, $untranslated_text, $domain) {
  if ($domain === 'asgaros-forum') {
    switch ($translated_text) {
      case 'Forum':
        $translated_text = 'My Board';
      break;
      case '%s Topics':
        $translated_text = '%s Threads';
      break;
      case '%s Topic':
        $translated_text = '%s Thread';
      break;
      case 'Last post':
        $translated_text = '';
      break;
    }
  }

  return $translated_text;
}

function change_ntranslations($translated_text, $single, $plural, $number, $domain) {
  if ($domain === 'asgaros-forum') {
    $translated_text = change_translations($translated_text, '', 'asgaros-forum');
  }

  return $translated_text;
}

 

good morning,

the Forum is already translated into Italian but I would like to change some words (unfortunately loco translate doesn’t change them for me).

1 – How can I find the value in php of the words to change?

I attach screenshots of the words I need.

Thanks

Uploaded files:
  • esempio-forum.jpg