转换后退按钮ionic 2 [英] translate back button ionic 2

查看:56
本文介绍了转换后退按钮ionic 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ionic 2中更改了后退"按钮的名称,但是有人知道如何使用ng2-translate转换此按钮吗?

I changed the name of the Back button in ionic 2 but does somebody know how you can translate this button with ng2-translate?

this.config.set('backButtonText', 'Go Back'); // < want to translate this with ng2-translate.

推荐答案

您可以在app.ts中翻译这样的反向文本(假设您已经成功实现了ng2-translate模块):

You can translate the back text like this (assuming you have already successfully implemented the ng2-translate module) in your app.ts:

initializeApp() {
    this.platform.ready().then(() => {
        this.config.set('backButtonText', this.translate.get('ui.general.back')['value']);
    });
}

有必要在ready函数中进行设置,因为本地化会异步加载,并且在这里您可以知道本地化文件已加载并且模块可以正常工作.

It is neccessary to set this in the ready-function because the localization loads async and this is the place where you know that the localization files have been loaded and the module is ready to work.

很明显,我已经在ui.general.back;)下的相应json文件中设置了翻译文本

Obviously I have set the translation text in the appropriate json-files under ui.general.back ;)

如果尚未访问配置,则需要将其导入:

If you have not yet accessed the config then you need to import it:

import {..., Config} from 'ionic-angular';

这篇关于转换后退按钮ionic 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆