Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change allItem.text and or filterText #41

Closed
alexisAvenel opened this issue Sep 7, 2017 · 1 comment
Closed

Cannot change allItem.text and or filterText #41

alexisAvenel opened this issue Sep 7, 2017 · 1 comment

Comments

@alexisAvenel
Copy link

alexisAvenel commented Sep 7, 2017

We can change allItem.checked correctly, but when we would to change allItem.text or filterText , 'All' and 'Filter' text are always there.

@alexisAvenel alexisAvenel changed the title Cannot change allItem.text Cannot change allItem.text and or filterText Sep 8, 2017
@alexisAvenel
Copy link
Author

Resolved ! Use i18n file like you and update values.

default-treeview-i18n.ts

import {Injectable} from '@angular/core';
import {I18n} from './i18n';
import {TreeviewI18n, TreeviewItem} from 'ngx-treeview';

@Injectable()
export class DefaultTreeviewI18n extends TreeviewI18n {
    constructor(protected i18n: I18n) {
        super();
    }

    getText(checkededItems: TreeviewItem[], isAll: boolean): string {
        if (isAll) {
            switch (this.i18n.language) {
                case 'en':
                    return 'All';
                case 'fr':
                    return 'Tous';
                default:
                    return 'Tất cả';
            }
        }

        switch (checkededItems.length) {
            case 0:
                switch (this.i18n.language) {
                    case 'en':
                        return 'Select options';
                    case 'fr':
                        return 'Sélectionner des options';
                    default:
                        return 'Chọn mục';
                }
            case 1:
                return checkededItems[0].text;
            default:
                switch (this.i18n.language) {
                    case 'en':
                        return `${checkededItems.length} options selected`;
                    case 'fr':
                        return `${checkededItems.length} options sélectionnées`;
                    default:
                        return `${checkededItems.length} mục đã được chọn`;
                }
        }
    }

    allCheckboxText(): string {
        switch (this.i18n.language) {
            case 'en':
                return 'All';
            case 'fr':
                return 'Tous';
            default:
                return 'Tất cả';
        }
    }

    filterPlaceholder(): string {
        switch (this.i18n.language) {
            case 'en':
                return 'Filter';
            case 'fr':
                return 'Filtrer';
            default:
                return 'Lọc';
        }
    }

    filterNoItemsFoundText(): string {
        switch (this.i18n.language) {
            case 'en':
                return 'No items found';
            case 'fr':
                return 'Aucunes catégories trouvées';
            default:
                return 'Không có mục nào được tìm thấy';
        }
    }

    tooltipCollapseExpand(isCollapse: boolean): string {
        if (isCollapse) {
            switch (this.i18n.language) {
                case 'en':
                    return 'Expand';
                case 'fr':
                    return 'Ouvrir';
                default:
                    return 'Mở rộng';
            }
        } else {
            switch (this.i18n.language) {
                case 'en':
                    return 'Collapse';
                case 'fr':
                    return 'Fermer';
                default:
                    return 'Thu lại';
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant