简体   繁体   English

如何在Google App Engine上部署Angular多语言应用程序

[英]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/clii18n 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/endist/my-app/esdist/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的根文件夹。

  • Add an index.html inside this folder (to redirect to default locale depending on browser preferences or by let user choosing). 在此文件夹中添加index.html(根据浏览器首选项或让用户选择,重定向到默认语言环境)。
  • Deploy entire folder as one app in GAE. 在GAE中将整个文件夹部署为一个应用程序。
  • Each localized app will be sub-folders, and then served by GAE as https:///xxxx.appspot.com/en/ ... 每个本地化的应用程序都是子文件夹,然后由GAE提供为https:///xxxx.appspot.com/en/ ...

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.

相关问题 如何使用 CI-CD 流程将 Angular8 应用程序部署到谷歌应用引擎? - How to deploy an Angular8 application to google app engine using CI-CD process? 使用Maven在Google App Engine上部署SpringBoot / Angular 4 - Deploy a SpringBoot / Angular 4 on Google App Engine with maven 使用 google Compute Engine 和 nginx 部署 angular 7 应用程序-不显示任何内容 - Deploy angular 7 app with google Compute Engine and nginx - display nothing 如何将 asp.net 核心(后端)和 angular 8(前端)应用程序一起部署到 Google App Engine? - How to deploy asp.net core (backend) and angular 8 (frontend) appplications together to Google App Engine? 将使用angular-cli创建的Angular4(Angular)部署到Google App Engine - Deploy Angular4 (Angular) created using angular-cli to Google App Engine 如何在 NodeJs/Angular App Google App Engine 中强制使用 SSL - How to force SSL in NodeJs/Angular App Google App Engine 将基本的Angular 2应用程序部署到Google App Engine - Deploying basic Angular 2 app to Google App Engine 将Angular 2应用程序部署到Google App Engine - Deploying Angular 2 app to Google App Engine 如何在柔性环境中将 Angular js 前端(静态文件)模块部署为 GCP App Engine 中的单独服务 - How to Deploy angular js frontend (static files) module as separate service in GCP App Engine in flexible environment 如何在不上传220MB的node_modules的情况下在App Engine上部署angular 4应用 - How to deploy angular 4 apps on app engine without uploading 220MB of node_modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM