mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 09:32:41 +00:00
fix: translate back button title
This commit is contained in:
@@ -13,15 +13,34 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Directive, ElementRef, ViewContainerRef} from '@angular/core';
|
import {
|
||||||
|
Directive,
|
||||||
|
ElementRef,
|
||||||
|
Host,
|
||||||
|
Optional,
|
||||||
|
Self,
|
||||||
|
ViewContainerRef,
|
||||||
|
} from '@angular/core';
|
||||||
import {SCIcon} from './icon';
|
import {SCIcon} from './icon';
|
||||||
import {IconReplacer} from './replace-util';
|
import {IconReplacer} from './replace-util';
|
||||||
|
import {TranslateService} from '@ngx-translate/core';
|
||||||
|
import {Subscription} from 'rxjs';
|
||||||
|
import {IonBackButton} from '@ionic/angular';
|
||||||
|
import {TitleCasePipe} from '@angular/common';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'ion-back-button',
|
selector: 'ion-back-button',
|
||||||
})
|
})
|
||||||
export class IonBackButtonDirective extends IconReplacer {
|
export class IonBackButtonDirective extends IconReplacer {
|
||||||
constructor(element: ElementRef, viewContainerRef: ViewContainerRef) {
|
private subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
element: ElementRef,
|
||||||
|
viewContainerRef: ViewContainerRef,
|
||||||
|
@Host() @Self() @Optional() private ionBackButton: IonBackButton,
|
||||||
|
private translateService: TranslateService,
|
||||||
|
private titleCasePipe: TitleCasePipe,
|
||||||
|
) {
|
||||||
super(element, viewContainerRef, 'shadow');
|
super(element, viewContainerRef, 'shadow');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,4 +51,18 @@ export class IonBackButtonDirective extends IconReplacer {
|
|||||||
size: 24,
|
size: 24,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.translateService.stream('back').subscribe((value: string) => {
|
||||||
|
this.ionBackButton.text = this.titleCasePipe.transform(value);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
for (const subscription of this.subscriptions) {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ import {IonBackButtonDirective} from './ion-back-button.directive';
|
|||||||
import {IonSearchbarDirective} from './ion-searchbar.directive';
|
import {IonSearchbarDirective} from './ion-searchbar.directive';
|
||||||
import {IonBreadcrumbDirective} from './ion-breadcrumb.directive';
|
import {IonBreadcrumbDirective} from './ion-breadcrumb.directive';
|
||||||
import {IonReorderDirective} from './ion-reorder.directive';
|
import {IonReorderDirective} from './ion-reorder.directive';
|
||||||
|
import {TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||||
|
import {CommonModule, TitleCasePipe} from '@angular/common';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
imports: [TranslateModule, CommonModule],
|
||||||
declarations: [
|
declarations: [
|
||||||
IconComponent,
|
IconComponent,
|
||||||
IonIconDirective,
|
IonIconDirective,
|
||||||
@@ -37,5 +40,6 @@ import {IonReorderDirective} from './ion-reorder.directive';
|
|||||||
IonSearchbarDirective,
|
IonSearchbarDirective,
|
||||||
IonBreadcrumbDirective,
|
IonBreadcrumbDirective,
|
||||||
],
|
],
|
||||||
|
providers: [TranslateService, TitleCasePipe],
|
||||||
})
|
})
|
||||||
export class IonIconModule {}
|
export class IonIconModule {}
|
||||||
|
|||||||
Reference in New Issue
Block a user