florrain / locale

Browser locale negotiation for node.js
MIT License
257 stars 36 forks source link

Coffee -> ES6 #40

Open florrain opened 7 years ago

florrain commented 7 years ago

Overview

This PR is bundling a bunch of things that I wanted to apply on the repo to make it a little more up-to-date, and hopefully easier to work with:

Publishing

Open to suggestions - I'm planning on publishing a 1.0.0beta version of the package first, before making it official and stable. I'm not too worried but I could have missed something. 🤞

TODO

Review

Tests have been ported to JS as well, but if you could make sure that the source files (especially the main src/index.js) doesn't introduce regression, that would be fantastic. Any additional tests are very welcome as well.

Testing

git clone https://github.com/florrain/locale.git
cd locale
git checkout repo-upgrade
npm install
npm link

cd ../express-application
npm link locale # install local version of the package

Something like this:

import http from 'http';
import express from 'express';
import locale from 'locale';

const app = express();
app.server = http.createServer(app);

app.use(locale(['en', 'de'], 'en'));

app.get('/', function (req, res) {
  res.json({ headers: req.headers, locale: req.locale });
});

app.server.listen(process.env.PORT || config.port);

console.log(`Started on port ${app.server.address().port}`);
zmagauina-fn commented 2 years ago

@florrain Can I help get these changes merged in?