 
           ###*
            * Pluralize string based on count
-           * @param {number} count           Current count
-           * @param {array}  forms           List of possible plural forms
-           * @param {string} locale = locale Locale name
+           * @param {number} count                  Current count
+           * @param {array}  forms                  List of possible plural forms
+           * @param {string} locale = currentLocale Locale name
            * @return {string} Pluralized string
           ###
-          env.addGlobal '_p', (count, locale = locale) ->
+          env.addGlobal '_p', (count, locale = currentLocale) ->
             smartPlurals.Plurals.getRule(locale)
             smartPlurals(count, forms)
 

  # Construct task
  Task = ->
    # Define targets, with unique options and files, for each locale
    locales.forEach (locale) =>
      localeDir    = resolveLocaleDir(locale)

      @[locale] = {}

      @[locale].options =
        paths: '<%= path.source.layouts %>/'
        autoescape: false
        data:  '<%= data %>'
        configureEnvironment: (env) ->
          # Append url with locale name based on whether it's base locale or not
          env.addFilter 'resolveUrl', (url, loc) ->
            loc = loc || locale
            return (if resolveLocaleDir(loc) then '/' + resolveLocaleDir(loc) else '') + url

          # Output or not locale name based on whether it's base locale or not.
          env.addFilter 'resolveLocaleDir', (loc) ->
            if resolveLocaleDir(loc) then '/' + resolveLocaleDir(loc) else ''

          # Load string from current locale
          env.addGlobal '_t', (string, ph) ->
            ph  = ph || {}
            sprintf(i18n.dgettext(locale, string), ph)

          # Load string from specified locale
          # @note So far `sprintf` support only named placeholders
          env.addGlobal '_dt', (loc, string, ph) ->
            loc = loc || locale
            ph  = ph || {}
            sprintf(i18n.dgettext(loc, string), ph)

          ###*
           * Nunjucks extension for Markdown support


          data.page = data.page || {}

          data.page.locale     = currentLocale
          data.page.url        = '/' + filepath
          data.page.breadcrumb = filepath.split('/')
          data.page.basename   = path.basename(@src[0], '.nj')
