NX Monorepo(14.3.6)不支持$局部化(Angular局部)
这是我安装了最新版本的NX MonorePo(NPX Create-NX-Workspace@最新)。 NX的当前最新版本为(14.3.6)。之后,我添加了Angular本地化软件包(npm install @angular/bentize
)。此时,添加i18n属性(<标题I18n> title</title>
)工作正常,并且将转换密钥提取到message.xlf文件中。
问题是,如果我尝试在这种情况下使用$本地化$局部化,则没有报告任何错误,但是当我尝试生成消息时,使用> ng extract-i18n test-app
。生成一个空的消息。xlf。
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = $localize`my-app`;
}
Messages.xlf
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-US" datatype="plaintext" original="ng2.template">
<body>
</body>
</file>
</xliff>
因此,问题是否支持NX Monorepo中的$本地化? 也许项目中缺少某些配置。
我在这里添加了一个链接到GitHub( https://github.com/github.com/hivaga/nx--nx--nx---可以找到当前NX设置的定位支持)。
PS我尝试了最新的香草角度应用程序设置,那里的本地化作品是预期的,因此显然问题仅在NX方面!
Here is the case I have installed latest version of nx monorepo (npx create-nx-workspace@latest). Currently latest version of nx is (14.3.6). After this I have added angular localization package (npm install @angular/localize
). At this point now adding i18n attribute (<title i18n>Title</title>
) works fine and the translation key is extracted into messages.xlf file.
The problem is if I try to use $localize inside a component in this case no error is reported but when I try to generate messages.xlf with ng extract-i18n test-app
. An empty messages.xlf is generated.
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = $localize`my-app`;
}
messages.xlf
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-US" datatype="plaintext" original="ng2.template">
<body>
</body>
</file>
</xliff>
So the question is there support for $localize inside NX Monorepo?
Maybe some configuration is missing in the project.json?
I am adding here a link to the github (https://github.com/hivaga/nx-localization-support) were current nx setup can be found.
PS I have tried latest vanilla angular application setup there $localize works as expected so obviously the problem is only on NX side!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了生成空的两个原因
messages.xlf
,而没有在同一时间报告任何错误:缺少Application的
polifills.js
组件 *.ts中的错误导入中缺少导入量。文件。基本上
$本地化
应在导入语句中没有任何引用。这很奇怪,但这是它的工作方式。I have found the 2 reasons for the generation of empty
messages.xlf
without in the same time reporting any errors:Missing import statment in application's
polifills.js
Wrong import inside the component's *.ts. file. Basically
$localize
should be used without any reference to it inside the import statements. This is rather weird but it is how it works.