mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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'}}"
|
{{if this.model.loadingBefore 'loading'}}"
|
||||||
>
|
>
|
||||||
<CountI18n
|
<CountI18n
|
||||||
@key="topic_count_"
|
@key="topic_count_latest"
|
||||||
@suffix="latest"
|
|
||||||
@count={{or this.model.loadingBefore this.incomingCount}}
|
@count={{or this.model.loadingBefore this.incomingCount}}
|
||||||
/>
|
/>
|
||||||
{{#if @model.loadingBefore}}
|
{{#if @model.loadingBefore}}
|
||||||
|
Loading…
Reference in New Issue
Block a user