2

Im currently using i18n on my angular 2 . In the DOM i can easily use the i18n attribute to translate whatever i want.

But i also have text-strings comming from the backend thats is mainly written in english (node.js).How would i go forward to translate that?

I heard that i could for example use ng2-translate in the angular service , but wouldnt it be a bad thing to use two seperatly services , one for backend and one for frontend?

What Would be the best way to solve this?

maria
  • 207
  • 5
  • 22
  • 56
  • using http://i18next.com -> runs both on node.js and on browser angular – jamuhl Jul 17 '17 at 18:49
  • True, @jamuhl but i dont SEE How Im supposed to translate results from backend node.js with params etc etc. – maria Jul 17 '17 at 18:51
  • eg. if you use express use https://github.com/i18next/i18next-express-middleware for koa there is another options...doing so you got access to req.t to translate content incl. interpolation, plurals...same functionality as on clientside – jamuhl Jul 17 '17 at 18:53
  • Thanks. Will look into it. How would i deal with variables? – maria Jul 17 '17 at 18:57
  • https://www.i18next.com/interpolation.html#unescape if you encounter any issue or problems on cofiguration - just open an issue on the repo...will help you there too (will be on holiday this week but back on next monday) – jamuhl Jul 17 '17 at 19:01

0 Answers0