2

How to translate the output of format_plural which returns a new translatable string every time the count increased.

I put the translation with @count but it returns an array like @count[NUMBER] the NUMBER increased and for every NUMBER we have a string that need translation.

The translation work if I put @count[NUMBER] and didn't work for NUMBER-1 nor NUMBER+1

How to translate all strings with one translation?

The code comes from download_count module

And here is the piece of code

if (isset($file->downloads) && $file->downloads > 0) {
$output .=     format_plural($file->downloads, 'Downloaded 1 time',     'Downloaded @count times');

}

Finally I need to translate plural strings form the translation interface drupal provides and fix the raised number of strings

I have .po files and had changed the plural-forms as that comment then import the file but nothing changed so I need help to fix it.

Thanks in advance

  • Welcome to Drupal Answers! You should show the code you are using, since it's not clear what you are saying; plus, without seeing the code is not possible to say what is wrong with the code. – kiamlaluno Sep 17 '13 at 6:57
  • It's not my code mean I need to translate the output of the function through drupal translation interface – Mohammed Gomma Sep 17 '13 at 7:02
  • As for "which returns a new translatable string every time the count increased," what is the string that you are trying to translate? If you are speaking of translating through the user interface, I am not sure what you mean by " it returns an array like @count[NUMBER] the NUMBER increased and for every NUMBER we have a string that need translation," since the user interface doesn't return an array. – kiamlaluno Sep 17 '13 at 10:35
  • Can't you just add 2 translations? One for "Downloaded 1 time" and one for "Downloaded @count times"? format_plural() calls t() internally so that would make most sense I think – Clive Sep 17 '13 at 11:27
  • I did but @count only works for the first time download mean the string is (downloaded 1 time).the second becomes (downloaded 2 time) --third (downloaded 3 time)Thus I have newly added strings needs translation I see that the plural forms isn't set correctlly – Mohammed Gomma Sep 17 '13 at 11:30
1

Thanks all

I found the solution as that comment form-plural in po

Edited on of the po files after exporting the last state to keep translation.

Import the file using drush (uploading from the interface always fail)

Installed drush_lang module

Apply that patch langimp relative path in /home/$_USER/.drush/drush_language

Clear cache for drupal and drush (drush cache-clear drush)

use the commands that module provides and every thing will be fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.