Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: Plural for Translated Modules

Submitted by on May 17, 2010 – 9:33 amNo Comment

So, you should create lines in your Drupal module as to plural work when translating to other languages.

You should specify in module’s code:

format_plural($day_count, ‘1 day’, ‘@count days’);

Format of format_plural() function:

D6: format_plural($count, $singular, $plural, $args = array(), $langcode = NULL)
D5: format_plural($count, $singular, $plural)

Parameters:
  • $count – number to be shown.
  • $singular – line for singular. Do not use @count in this line.
  • $plural – line for plural. Use @count where number should be placed. For example "@count new comments".
  • $args – associative array of replacements which are made after translation(there is no such parameter in Drupal 5 and lower). Incidences of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed:
    • !variable: is inserted as is
    • @variable: escape plain text to HTML (check_plain)
    • %variable: escape text and theme as a placeholder for user-submitted content (check_plain + theme_placeholder)

    ATTENTION: you do not need to include @count to this array. This replacement is made automatically for prural.

  • $langcode – unnecessary code of language different from language that is used to show page (there is no such parameter in Drupal 5 and lower).

Example:

  $output = format_plural($update_count,
  ‘Changed the content type of 1 post from %old-type to %new-type.’,
  ‘Changed the content type of @count posts from %old-type to %new-type.’,
  array(‘%old-type’ => $info->old_type, ‘%new-type’ => $info->new_type)));

Po-file will contain the following code after extracting of lines and translation:

msgid "1 day"
msgid_plural "@count days"
msgstr[0] "@count day"
msgstr[1] "@count day"
msgstr[2] "@count days"

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.