Title: multilanguage shortcode
Last modified: August 9, 2024

---

# multilanguage shortcode

 *  [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/)
 * I have some problems with the following
 *     ```wp-block-code
       add_shortcode('periodo_affitti', 'translate_rent');function translate_rent() {  global $post;  $lang = substr( get_locale(), 0, 2 );if ('it' != $lang )   { $period_lang= get_the_author_meta('periodo_affitti_$lang', $post->post_author);     if ( ! empty(  $period_lang)         return $period_lang ;     } else {        return $period_lang;     }   } else {     return $period_lang;}}, 10, 2 );
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fmultilanguage-shortcode%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/#post-17944273)
 * What exactly is the question?
 *  Thread Starter [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/#post-17944621)
 * Many questions. I’ll start with:
 * 1)There is 1 more closing curly braces ‘}’ found, I cant see where..
 * 2)I wonder if it’s possible to use a “return” in a shortcode
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/#post-17944680)
 * You are missing a `)` here:
 *     ```wp-block-code
       if ( ! empty( $period_lang)
       ```
   
 * Correct would be:
 *     ```wp-block-code
       if ( ! empty( $period_lang ) )
       ```
   
 * And shortcodes _must _return the output via return. There is no other possibility.
 *  Thread Starter [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/#post-17944727)
 * I think there are more faults with parenthesis…:(
 *  Thread Starter [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/#post-17947639)
 * I had to change ‘periodo_affitti_$lang’ into “periodo_affitti_$lang”

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘multilanguage shortcode’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 2 participants
 * Last reply from: [sacconi](https://wordpress.org/support/users/sacconi/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/multilanguage-shortcode/#post-17947639)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
