[英]How to deploy Angular multilanguage application on Google App Engine
I've built my Angular 8 application, with angular/cli
and i18n multilanguage support
(with translations for English, Spanish, French). 我已经构建了我的Angular 8应用程序,支持angular/cli
和i18n multilanguage support
(英语,西班牙语,法语翻译)。
So that I can build my app multiple times, one for each language and the build is saved in dist/my-app/en
, dist/my-app/es
, dist/my-app/fr
and so on... 这样我可以多次构建我的应用程序,每种语言一个,构建保存在dist/my-app/en
, dist/my-app/es
, dist/my-app/fr
等等......
Now I'd like to deploy my app on Google App Engine, but I cannot understand what I should do/configure to deploy all my lang specific versions of my app. 现在我想在谷歌应用引擎上部署我的应用程序,但我无法理解我应该做什么/配置部署我的应用程序的所有lang特定版本。
I've already published my default (English) version on GAE and it works, but I don't know how/where to deploy all the other versions (es, fr, etc). 我已经在GAE上发布了我的默认(英文)版本并且它可以工作,但我不知道如何/在哪里部署所有其他版本(es,fr等)。
Should I use the dispatch file? 我应该使用调度文件吗? What's your best way to do that? 你最好的方法是什么?
Thanks! 谢谢!
You can consider dist/my-app
as your root folder regarding AppEngine. 您可以将dist/my-app
视为关于AppEngine的根文件夹。
To build multiple application with multiple locales, check Angular official docs . 要使用多个语言环境构建多个应用程序,请查看Angular官方文档 。
Each href should be set to locale: 每个href应设置为locale:
"baseHref": "/en/",
Then, update app.yaml
and handlers to serve all sub-folders. 然后,更新app.yaml
和处理程序以提供所有子文件夹。
For instance, this should looks like : 例如,这应该是这样的:
handlers:
- url: /fr/(.+)
static_files: app/fr/index.html
upload: app/fr/index.html
- url: /en/(.+)
static_files: app/en/index.html
upload: app/en/index.html
- url: /(.+)
static_files: app/index.html
upload: app/index.html
- url: /
static_files: app/index.html
upload: app/index.html
But I'm not an expert of handlers regexp, so it could be optimized I'm sure. 但我不是处理程序regexp的专家,所以我可以对它进行优化。
Deploy folder should looks like : 部署文件夹应如下所示:
deploy
app.yaml
app
index.html // page to propose user to select locale or auto redirect
fr
index.html
bundles.js...
en
index.html
bundles.js...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.