I would like to compile my angular application aot. My translations are saved on the server in a database. These translations can be changed by the users. So is there any way to get these changes to work with the aot compilation if a user changed the translation?
Asked
Active
Viewed 1,068 times
0
-
AOT doesn't change anything to how you get data from your server. Whether you use AOT or not doesn't change anything. – JB Nizet Jun 19 '18 at 20:16
-
Yes but I thought aot compiles the finished files for every language with ngx translate. So how it will translate them then?ngx translate works also with aot mode. – Franki1986 Jun 19 '18 at 20:23
-
Your assumption is incorrect. The translation happens at runtime with ngx-translate. You seem to confuse ngx-translate with the native i18n support of Angular. they don't work the same way at all. – JB Nizet Jun 19 '18 at 20:24
-
Ok.. I knew this would come :-)it is not realy clear how it works exactly with the combination of ngx translate. – Franki1986 Jun 19 '18 at 20:26
-
How *what* works? – JB Nizet Jun 19 '18 at 20:33
-
Ngx translate if my application is compiled in aot mode. Where is the benefit if ngx translate works also in this mode if it works the same way like in jit mode. – Franki1986 Jun 19 '18 at 20:37
-
The benefit of AOT compilation is that the bundle doesn't need to contain the template compiler anymore, making it much smaller. It's also that HTML templates are precompiled, making the application start much faster since templates don't need to be compiled at startup in the browser. And since the AOT compiler compiles to TypeScript first, it allows detecting errors in your template at build time that would be only detected at runtime with JIT, or wouldn't be detected at all. All this is very useful, but has nothing to do with ngx-translate. – JB Nizet Jun 19 '18 at 20:41
-
ngx-translate is just a pipe, a service and a directive allowing to translate keys into values, at runtime. – JB Nizet Jun 19 '18 at 20:41
-
Thanks for the clarification! If you like you can put your comments into an answer, so I can upvote and mark it as solution. – Franki1986 Jun 19 '18 at 20:43
1 Answers
1
The benefit of AOT compilation is that
- the bundle doesn't need to contain the template compiler anymore, making it much smaller.
- HTML templates are precompiled, making the application start much faster since templates don't need to be compiled at startup in the browser
- since the AOT compiler compiles to TypeScript first, it allows detecting errors in your template at build time that would be only detected at runtime with JIT, or wouldn't be detected at all.
All this is very useful, but has nothing to do with ngx-translate. ngx-translate is just a pipe, a service and a directive allowing to translate keys into values, at runtime.

JB Nizet
- 678,734
- 91
- 1,224
- 1,255