Angular-使用自定义过滤器进行翻译

Angular-Translate with custom filter

我如何使用我自己的自定义过滤器来格式化,比如说,一周中的每一天不是星期日、星期一...而是使用我的 $translate 服务。例如

app.filter('formatDate', ['$translate', function ($translate) {
return function (date) {
    var now = new Date();
    var date = new Date(date);
    var monthNames = [
        "Jan", "Feb", "March",
        "Apr", "May", "June", "July",
        "Aug", "Sept", "Oct",
        "Nov", "Dec"
    ];
    dayNames = [
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
    ];

    var formattedDate;
    ...
    ...

    if (now.getDate() == date.getDate() && now.getMonth() == date.getMonth() && now.getFullYear() == date.getFullYear()) {
        if (diffSeconds < 120) {
            formattedDate = 'few seconds ago';
        }
        else {
            if (diffSeconds <= 300) {
                formattedDate = Math.round(diffSeconds / 60) + ' minutes ago';
            }
            else {
                formattedDate ='at '+hours + ':' + minutes + ampm;
            }
        }
    }
    else {
        if(diffDays == 1)
            formattedDate = 'yesterday';
        else {
            if (diffDays < 7){
                formattedDate = 'on ' + dayNames[date.getDay()];
            }
            else{
                formattedDate = monthNames[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();
                }
            }
        }

    return formattedDate;
};
}]);

我怎样才能让数组 dayNames 使用我转换后的周数?

我用 $translate.instant() 解决了这个...

dayNames = [
    $translate.instant("Sunday"), 
    $translate.instant("Monday"), 
    $translate.instant("Tuesday"), 
    $translate.instant("Wednesday"), 
    $translate.instant("Thursday"), 
    $translate.instant("Friday"), 
    $translate.instant("Saturday")
];