mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 13:03:45 +08:00
DEV: Convert count-i18n to gjs (#26888)
This commit is contained in:
parent
79870d3a1e
commit
16cd098de9
|
@ -0,0 +1,26 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { service } from "@ember/service";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import i18n from "discourse-common/helpers/i18n";
|
||||
|
||||
export default class CountI18n extends Component {
|
||||
@service currentUser;
|
||||
|
||||
get fullKey() {
|
||||
let key = this.args.key;
|
||||
|
||||
if (this.args.suffix) {
|
||||
key += this.args.suffix;
|
||||
}
|
||||
|
||||
if (this.currentUser?.new_new_view_enabled && key === "topic_count_new") {
|
||||
key = "topic_count_latest";
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
<template>
|
||||
<span>{{htmlSafe (i18n this.fullKey count=@count)}}</span>
|
||||
</template>
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{{this.i18nCount}}
|
|
@ -1,21 +0,0 @@
|
|||
import Component from "@ember/component";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "span",
|
||||
i18nCount: null,
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
let fullKey = this.key + (this.suffix || "");
|
||||
if (
|
||||
this.currentUser?.new_new_view_enabled &&
|
||||
fullKey === "topic_count_new"
|
||||
) {
|
||||
fullKey = "topic_count_latest";
|
||||
}
|
||||
this.set("i18nCount", htmlSafe(I18n.t(fullKey, { count: this.count })));
|
||||
},
|
||||
});
|
|
@ -36,8 +36,7 @@
|
|||
{{if this.model.loadingBefore 'loading'}}"
|
||||
>
|
||||
<CountI18n
|
||||
@key="topic_count_"
|
||||
@suffix="latest"
|
||||
@key="topic_count_latest"
|
||||
@count={{or this.model.loadingBefore this.incomingCount}}
|
||||
/>
|
||||
{{#if @model.loadingBefore}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user