summaryrefslogtreecommitdiff
path: root/src/node/hooks/i18n.js
blob: ab0a887b73c45bce76669a4f94506750e24e0dca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var Globalize = require('globalize')
  , fs = require('fs')
  , path = require('path')

fs.readdir(__dirname+"/../../locales", function(er, files) {
  files.forEach(function(locale) {
    locale = locale.split('.')[0]
    if(locale.toLowerCase() == 'en') return;
    require('globalize/lib/cultures/globalize.culture.'+locale+'.js')
  })
})

exports.expressCreateServer = function(n, args) {

  args.app.get('/locale.ini', function(req, res) {
    
    Globalize.culture( req.header('Accept-Language') || 'en' );
    var localePath = path.normalize(__dirname +"/../../locales/"+Globalize.culture().name+".ini");
    res.sendfile(localePath, function(er) {
      if(er) console.error(er)
    });
  })
  
}