-
Notifications
You must be signed in to change notification settings - Fork 877
Update i18n documentation (2.4.x): System is not defined #3279
Comments
Took me ages to figure this out. Documentation should be updated. Probably the problem is that the documentation suggests Angular CLI which is not using system.js. Also System.js has the global namespace "SystemJS" instead of "System".
Finally it looks like this: index.html
i18n-providers.ts
|
That is not the proper solution for the CLI either. We are cooking a solution for certain guides to provide alternative solutions for the CLI and webpack. Closing as duplicated (#3238) |
At least it is a solution. Someone who reads the cookbook is probably unexperienced like me and ends frustrated there. |
Believe me, it is not. That will only lead to more grief and pain. |
Could you please explain why its pain because my project is nearly in production with this. There were no other help, tutorials or answers in the whole www. |
Because you are mixing different loaders. CLI uses webpack so you need to use a webpack solution. System.JS is another option. It is like riding a motorbike inside a car because one tire was flat. @filipesilva do you have any idea in how to do it with the CLI? |
Ah okay see i didn't know that! Funny to get some light in the dark. I wouldn't compare it like this. Lets say i drive with a car around the world but to get food i use a motorcycle? The only need of system.js in my project is to load the translation files. There are probably lighter solutions than 18kb JavaScript + text-plugin. Thanks for your answer! In my opinion documenation should be updated as fast as possible. At least there should be a warning like "Angular CLI is not using system.js". While we are talking probably more and more users get trapped there. |
No, you are mixing both together, at the same time. I bet the CLI can load your translations files without anything extra nor system.js. Let's see if Filipe has something to say or I will try later myself. |
I guess its good like this because i use AOT-compilation while he grabs translations with system.js JIT. (AOT translation-documentation is missing some extra work which is not covered on official documentation nor anywhere i found) |
Heya @MickL, I have good news and bad news. Good news is that i18n use/extract functionality is present in the CLI. Bad news is that it's fairly new it's not well documented. We have an issue to track documentation for this, but it hasn't been documented yet: angular/angular-cli#2711 The best I can do right now is to point you to the tests to see how we test it's working. The gist of it is that you can extract the messages using Translation usage test: https://github.com/angular/angular-cli/blob/master/tests/e2e/tests/build/aot/aot-i18n.ts |
Correct me if I'm wrong, from what I see in the tests, it seems the i18n is static? You cant have a multi-lang application? You have to build one application for each language? |
The documentation shows the JIT method where you have only one build. Actually i use a single AOT prebuild app with JIT translations. You could improve performance by prebuild every language separate which is barely covered in documentation. |
Yes but as @Foxandxss said the JIT method use SystemJS, it's not a viable option. |
@filipesilva Does it create a single index.html and a separate build for every language? Would be awesome! (Looking forward for the documentation. Wiki looks great already!) |
So is a JIT version for i18n translations in CLI coming or will there only be AOT support? |
Following the i18n cookbook i get
System is not defined
.Im using latest Angular CLI. My index.html looks like this:
The text was updated successfully, but these errors were encountered: