- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 ngx-translate 和 ngx-translate/http-loader 来翻译我的 ionic/angular 项目。我在 app.module.ts 导入中有这段代码:
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpBackend]
}
})
和这个加载器函数在同一个文件中:
export function createTranslateLoader(handler: HttpBackend) {
const http = new HttpClient(handler);
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
这让我有机会在组件的 html 中使用这种翻译语法:{{ 'TEXT' | translate }}
,我也可以写一些类似的东西来翻译组件的 ts 文件: var text = this.translateService.instant("TEXT");
现在我想在命令 "ng generate s"
生成的服务中使用 translateService.instant
我试过了,但它不起作用,它返回 “TEXT”
本身。那么问题是什么?
最佳答案
试试 this.translateService.get("TEXT").subscribe(...)
参见:https://github.com/ngx-translate/core#4-use-the-service-the-pipe-or-the-directive
instant(key: string|Array, interpolateParams?: Object): string|Object: Gets the instant translated value of a key (or an array of keys). /!\ This method is synchronous and the default file loader is asynchronous. You are responsible for knowing when your translations have been loaded and it is safe to use this method. If you are not sure then you should use the get method instead.
关于Angular ngx-translate 内部服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54592537/
我听说 Translate API 需要付费,但究竟是什么阻止了我们使用免费的 Google 翻译服务 here免费 ?否则,免费服务的限制是什么? 最佳答案 根据下面的链接,没有什么可以阻止您。 h
我正在修复我的 Karma 配置以运行 Angular2 - rc 1 版本的测试。我可以运行测试,但如果我在 html 中有一个翻译管道,它们就会失败。(我可以让它工作的配置是从 [这里][1] 得
我正在使用以下代码: GttService myService = new GttService("ex1cor.ex1Ap.1"); myService.setUserCredentials("ex
是否可以在 Silverstripe 3 中翻译数据对象? 我使用这个模块: http://www.silverstripe.org/translatable-module/ 在我的配置中是否定义了以
我有以下三个问题 我想使用 Google 的 API 来翻译文本。我知道谷歌对翻译和检测单独收费。谷歌翻译也支持翻译两种翻译方式 i) 通过指定源和目标,如 https://www.googleapi
我一直在使用 Microsoft Translator 的 HTTP API 来翻译我网站上的文本。 作为the documentation describes , 有一个选项可以指定翻译的类别。找不
当您在 localhost 上开发应用程序时,是否有机会在不获取 key 的情况下使用 Use Google Translation API? 我希望这样的事情能够奏效' https://www.go
我正在尝试翻译实体的某些字段,但在尝试创建对象时出现以下错误... id; } /** * Set name * * @param string $nam
当用户访问我们的网站时,我们使用 Google Translate API 将我们的内容翻译成用户的语言。 (当然,我们遵循署名和链接要求,以便用户知道内容是 Google 的翻译。) 为了优化,我们
我非常频繁地使用谷歌翻译 API V2,在大约 2000 个请求之后,我开始在返回的 JSON 中得到这个: Array ( [error] => Array (
我刚开始使用 Google 翻译 API,在测试过程中我们注意到,对于某些翻译(我尚未找到模式),我们会在响应中收到\u200b 字符。这会导致很多问题,最重要的是,它似乎没有任何目的或没有任何意义。
从laravel 5.8升级到laravel 6.0后,发现这个错误。 Method Illuminate\Translation\Translator::getFromJson does not e
这是一个基本的移动滑入/滑出菜单。 我发现很难调试,但基本上我的问题是,当我按下菜单按钮时,菜单会顺利打开,再次按下它会顺利关闭。然而,当我再次按下它(第三次)时,它不顺利打开,它只是出现。但是它仍然
我的 Android Studio 的翻译编辑器无法正常工作。如果我打开翻译编辑器确实列出了字符串的正确键,但是找不到默认值和翻译。所有键都有一个默认值,其中大多数也有一个翻译。 我重新启动了 And
我正在尝试从 python 控制台而不是通过 bazel -build 运行 Tensorflow 的 translate.py,但我在这两行出现错误: from tensorflow.models.
本文整理了Java中org.apache.tika.language.translate.YandexTranslator.translate()方法的一些代码示例,展示了YandexTranslat
我需要来自 Google Transle API 的同义词信息。有没有可能得到它? 最佳答案 抱歉不行。看到这个 post .看起来他们opened a PIT添加功能。你应该给它加星号来增加重量!
我在我的一个项目中使用 Google Cloud Translation API。我想指定翻译的性别。我无法在 Google Cloud Translation 中找到相关信息。我也在互联网上搜索了很
我已经在我的 Angular-Cli 应用程序中实现了 ngx-translate 并且在我执行以下操作时工作正常: {{ 'some.value' | translate }} 但是我该如何翻译 H
我决定在我的项目中使用 Google Cloud Translation API。在我尝试运行他们的脚本之前,一切似乎都很好。它总是说我需要“使用 require([])”。 在我在 require
我是一名优秀的程序员,十分优秀!