Core: Does not work with angular universal

Created on 8 Dec 2016  路  23Comments  路  Source: ngx-translate/core

I'm submitting a ...
[x ] bug report

Error output
ORIGINAL EXCEPTION: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie

Please tell us about your environment:

  • OS: Mac OS X Sierra 10.12.1
  • Node: v6.9.1
  • NPM: v3.10.8
  • angular2-universal: v2.0.11

  • ng2-translate version: 4.2.0

  • Angular version: 2.1.0

  • Browser: All

  • Language: TypeScript 2.0.3

high TODO bug

Most helpful comment

for anything that depends on HttpModule make sure you include it before UniversalModule

All 23 comments

Hi, where is this getCookie method ? It's not in ng2 translate source code

@ocombe check this console output

Hmm seems like it's a problem with the HttpModule from Angular, did you use a version not supported by your current angular universal version ?
Let's ask @patrickjs if he has any advice on this

Angular universal has its own HttpModule so I didn't import it from angular/http. I think this is a problem.

Anyone can help out?

+1 I have the problem to

Hi,
I have the solution,

In your browser.module and node.module, add the UniversalModule last in the imports array.
This makes sure that Anuglar Universal overrides the HtppModule!

for anything that depends on HttpModule make sure you include it before UniversalModule

@zwaldeck @gdi2290 thank you so much It works now :)

If i put the UniversalModule at the end of imports array I get this error:
Response with status: 404 null for URL:

the array is:

  imports: [
    FormsModule,
    RouterModule.forRoot([], { useHash: false }),
    AppModule,
    SharedModule.forRoot(),
    UniversalModule,
  ]

Hello! I have the same problem.
I move UniversalModule after HttpModule:

let imports = [
  HttpModule,
  UniversalModule,
  FormsModule,
  ReactiveFormsModule,
  RouterModule,
  routing,
  NgbModule.forRoot(),
  ClickOutsideModule
];

The error in console solved, but app is not works.
localhost:4200 response empty data: http://jmp.sh/diuSLEl

any update?

Any update on this?

It works with Universal (old version), I haven't tried with the new universal that is being merged into v4 but it should work too. I removed the HttpModule dependency from the core in 6.0, you can use the main module in the server and in the browser, just load a different TranslateLoader (ex: HttpLoader in the browser, and UniversalLoader in the server)

Llevo m谩s de dos semanas tratando de que esto funcione:

UniversalModule + @ngx-translate + webpack

Que mierda, est谩s tecnolog铆as no las han terminado de inventar.

Could you at least try to use English as communication language. Thanks!

Cristian cual es tu problema? creo que puedo ayudarte

@cristiancamiloperezlopez this project is open source, it's free and we work on it on our free time.
If you're not happy with it, either try to improve it, or write your own thing but don't come here to insult us.
One more message like this and I'll ban you from this repository

Hello @ocombe excuse my English

I know perfectly well that it is an open source project, but you must understand that it is very frustrating for a developer who for some reason chose this technology for his project and after a month of hard work, study and research can not make a simple Translation of a text works correctly.
The insult was never personal, I never said developers or that team suck. I mean it's my personal case and the combination of UniversalModule + @ ngx-translate + webpack that does not work now.
Now if you want to ban me because of this, I will not end the world if I change technology or if I stop writing in this repository.

Hello @martinop excuse my English

The problem is that I'm using UniversalModule + @ ngx-translate + webpack in a project and I have the following situation:

In app.module:

If in the matrix of imports I leave UniversalModule last I have this error:

Unexpected token in JSON at position 0

Resource files (i18n / es.json and i18n / en.json) are available from the browser.

And if I leave first, I have this other error:

This method is not implemented in Parse5DomAdapter: Parse5DomAdapter # getCookie

Is there anything I can try? Thank you very much !

Here is what I used for a project with universal: https://gist.github.com/ocombe/8af9d555ab2da45cd1042ef2ccb0ef6b

This is with universal for angular 2.1.2 and ng2-translate 4.1.0, you can migrate it to ngx-translate, it shouldn't be too difficult.

I haven't tried universal in angular 4 yet, a lot of things have probably changed.

@cristiancamiloperezlopez I dont need to put the universalmodule at the end of the array.. Just do this:

https://github.com/angular/universal-starter/issues/263

Basically you need to implement your own loader for the server side..
in the app.browser just import all normally and in the app.node put the ngx translate in the imports arry using your own loader as in the example

@ocombe and @martinop

Thank you both, problem solved.
I'm going to cry about happiness, I really was very frustrated by this situation.
@ocombe sorry for my bad words, I will be more tolerant of any technology that I am using 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dankerk picture dankerk  路  3Comments

jellene4eva picture jellene4eva  路  3Comments

alkemist picture alkemist  路  3Comments

IterationCorp picture IterationCorp  路  3Comments

ryanki1 picture ryanki1  路  4Comments