How dynamically the momentjs language is required

Hi, I am using expressjs for a backend service where I need to set the locale for momentjs based on a custom browser. Im looking for any moment/locale/{locale-file based}expressjs based download strategies request.acceptsLanguages.

Any help is appreciated

+6
source share
1 answer

You can simply use the function .locale()after parsing the correct language from the query (but you at least sent the language header)

const moment = require('moment');
const language = getLanguageFromRequest(req); // or whatever logic you like
moment.locale(language);

but it might be better to handle it in a browser rather than in a backend.

0
source

Source: https://habr.com/ru/post/1668433/


All Articles