Lad*_*dos 3 internationalization amazon-cloudfront angular
我有一个Angular应用程序,该应用程序存储在AWS S3存储桶中,并由Cloudfront分发。
现在,我想以多种语言发布我的应用程序。我已经翻译了我的角度应用程序和构建中使用的每种语言。
因此,我的S3存储桶如下所示:
de
/index.html
/script.js
en
/index.html
/script.js
Run Code Online (Sandbox Code Playgroud)
对于每种语言,我想提供另一个应用程序。
在Cloudfront中,我创建了两个Origins,分别指向Origin Path /de和/en
所以我的URL架构是这样的:
<appname>.<mydomain>.com/:lang
Run Code Online (Sandbox Code Playgroud)
但是我的问题是,我没有使用这些特定语言文件夹的错误页面。我需要这些错误响应处理程序,以在发生404错误时(由于重新加载)交付有角度的应用程序
有谁知道我该怎么解决?还是应该为每种语言再创建一个子域?所以看起来像这样:
<lang>.<appname>.<mydomain>.com
Run Code Online (Sandbox Code Playgroud)
我最近遇到了同样的问题。我的情况:
解:
ng build -prod -aot --base-href / en / --i18nFile = src / locale / messages.en.xlf --i1nFormat = xlf --locale = en
const path = require('path')
exports.handler = (evt, ctx, cb) => {
const { request } = evt.Records[0].cf
if (!path.extname(request.uri)) {
if (request.uri.startsWith('/fr'))
request.uri = '/fr/index.html'
else
request.uri = '/en/index.html'
}
cb(null, request)
}Run Code Online (Sandbox Code Playgroud)
使用基本路径参数构建Angular将为Angular应用建立正确的子目录。重写将确保不会重写资源文件,但是所有路由都会重定向到index.html
| 归档时间: |
|
| 查看次数: |
1607 次 |
| 最近记录: |