Title: time passed translation function
Last modified: February 20, 2024

---

# time passed translation function

 *  [angel696](https://wordpress.org/support/users/angel696/)
 * (@angel696)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/time-passed-translation-function/)
 * Hi, this function have an issue……all words are translated on file.po, but the
   time is not showed. I have this worning: ” Undefinited array key “anno” in /…..
   helpers.php on line 208.
 * This Is line 208: **return** sprintf( esc_html__(‘%s %s ago’, ‘brikk’), $r, $
   r > 1 ? $a_plural[ $str ] : $str );
 * file.po: %s %s ago —– translation on loco %s %s fa’
 * thi is the function:
 * public function get_time_elapsed_string( $time ) { $etime = time() – $time; if(
   $etime < 1 ) { return ‘0 seconds’; } $a = [ 365 * 24 * 60 * 60 => esc_html__(‘
   year’, ‘brikk’), 30 * 24 * 60 * 60 => esc_html__(‘month’, ‘brikk’), 24 * 60 *
   60 => esc_html__(‘day’, ‘brikk’), 60 * 60 => esc_html__(‘hour’, ‘brikk’), 60 
   => esc_html__(‘minute’, ‘brikk’), 1 => esc_html__(‘second’, ‘brikk’) ]; $a_plural
   = [ ‘year’ => esc_html__(‘years’, ‘brikk’), ‘month’ => esc_html__(‘months’, ‘
   brikk’), ‘day’ => esc_html__(‘days’, ‘brikk’), ‘hour’ => esc_html__(‘hours’, ‘
   brikk’), ‘minute’ => esc_html__(‘minutes’, ‘brikk’), ‘second’ => esc_html__(‘
   seconds’, ‘brikk’) ]; foreach( $a as $secs => $str ) { $d = $etime / $secs; if(
   $d >= 1 ) { $r = round( $d ); return sprintf( esc_html__(‘%s %s ago’, ‘brikk’),
   $r, $r > 1 ? $a_plural[ $str ] : $str ); } } }
 * Somebody can help me!
 * Thanks.
    -  This topic was modified 2 years, 4 months ago by [angel696](https://wordpress.org/support/users/angel696/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ftime-passed-translation-function%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [angel696](https://wordpress.org/support/users/angel696/)
 * (@angel696)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/time-passed-translation-function/#post-17442365)
 * Hi,
 * if I not translate the singolar …then it show the plurar, but in this way
 * I lose the translation for the singolar.

Viewing 1 replies (of 1 total)

The topic ‘time passed translation function’ is closed to new replies.

 * ![](https://ps.w.org/loco-translate/assets/icon-256x256.png?rev=1000676)
 * [Loco Translate](https://wordpress.org/plugins/loco-translate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/loco-translate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/loco-translate/)
 * [Active Topics](https://wordpress.org/support/plugin/loco-translate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/loco-translate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/loco-translate/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [angel696](https://wordpress.org/support/users/angel696/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/time-passed-translation-function/#post-17442365)
 * Status: not resolved