Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter quelicm

    (@quelicm)

    Hi Chouby, forgive the delay

    Polylang version: 1.8.4
    WP version: 4.4.2

    Settings:
    URL modifications
    – The language is set by the directory name in custom permalinks
    – Hide URL language information for the default language (check)
    – Remove /language/ in pretty permalinks

    Thanks

    Thread Starter quelicm

    (@quelicm)

    That quickly!

    Thank you chouby, the solution works properly.

    function pll__get_translate($string,$language){
          global $polylang;
        $language = $polylang->model->get_language($language); // import_from_db expects a language object
    
        $mo = new PLL_MO();
        $mo->import_from_db($language); // import all translations in $language
    
        // then you can translated any registered string with:
        $translated_string = $mo->translate($string);
    
        return $translated_string;
      }
    
      echo pll__get_translate('name','es'); //Nombre
      echo pll__get_translate('name','en'); //Name
    
    Thanks!!
Viewing 2 replies - 1 through 2 (of 2 total)