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 » Uncategorized

Drupal: Plural Noun Forms For Translated Articles

Submitted by on March 21, 2012 – 2:34 pmNo Comment

From this article, you will get know how to configure a module so that when you translate a site to other languages plural forms work correctly.

Solution:

You need to specify the following in the 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 – a number to show
  • $singular – line for singular. Don’t use @count there.
  • $plural – line for plural. Use @count instead of a number. E.g. , “@count new comments”.
  • $args – associative array of replacements which are made after translation (there is no such parameter in Drupal 5 or less). 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: 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)

    Note: you don’t need to include @count to this array. This is an automatic replacement for plural forms.

  • $langcode – un-compulsory language code for translating to a language which is not used to show a page (there is no such parameter in Drupal 5 or less).

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 then:

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

 

Good luck!

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.