document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. sub = (txt, context) ->
  2.     txt.replace /\\{\\{(.+?)\\}\\}/g, (whole, part) ->
  3.         context[part.trim()]
  4.  
  5.  
  6. UI.registerHelper \'i18n\', (tag, context) ->
  7.     c = context.hash
  8.     count = c.count
  9.  
  10.     try
  11.         if count is undefined
  12.             t = i18n.findOne({tag: tag}).value
  13.             return sub(t,c)
  14.         else            
  15.             ranges = (x.count for x in i18n.find({tag: tag}).fetch())
  16.             flag = false
  17.             for r in ranges
  18.                 if /../.test r                    
  19.                     r_min_r_max = r.split(\'..\')
  20.                     r_min = r_min_r_max[0]
  21.                     r_max = r_min_r_max[1]
  22.                     if (r_min == \'\' and r_max == \'\') or (r_min == \'\' and count <= parseInt(r_max)) or
  23.                        (r_max == \'\' and count >= parseInt(r_min)) or (parseInt(r_min) <= count <= parseInt(r_max))
  24.                         flag = true
  25.                         break
  26.                 else
  27.                     if parseInt(r) == count
  28.                         flag = true
  29.                         break
  30.             if flag
  31.                 t =  i18n.findOne({tag: tag, count: r}).value
  32.                 return sub(t, c)
  33.             else
  34.                 \'not found.\'
  35.     catch error
  36.         console.log error
  37.         \'not found..\'
');