mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't store translated trust level names in anonymous cache (#13224)
Refactors `TrustLevel` and moves translations from server to client Additional changes: * "staff" and "admin" wasn't translatable in site settings * it replaces a concatenated string with a translation * uses translation for trust levels in users_by_trust_level report * adds a DB migration to rename keys of translation overrides affected by this commit
This commit is contained in:
@@ -179,8 +179,10 @@ Site.reopenClass(Singleton, {
|
||||
}
|
||||
|
||||
if (result.trust_levels) {
|
||||
result.trustLevels = result.trust_levels.map((tl) =>
|
||||
TrustLevel.create(tl)
|
||||
result.trustLevels = Object.entries(result.trust_levels).map(
|
||||
([key, id]) => {
|
||||
return new TrustLevel(id, key);
|
||||
}
|
||||
);
|
||||
delete result.trust_levels;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import RestModel from "discourse/models/rest";
|
||||
import { fmt } from "discourse/lib/computed";
|
||||
import { computed } from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default RestModel.extend({
|
||||
detailedName: fmt("id", "name", "%@ - %@"),
|
||||
});
|
||||
export default class TrustLevel {
|
||||
constructor(id, key) {
|
||||
this.id = id;
|
||||
this._key = key;
|
||||
}
|
||||
|
||||
@computed
|
||||
get name() {
|
||||
return I18n.t(`trust_levels.names.${this._key}`);
|
||||
}
|
||||
|
||||
@computed
|
||||
get detailedName() {
|
||||
return I18n.t("trust_levels.detailed_name", {
|
||||
level: this.id,
|
||||
name: this.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@ export default {
|
||||
small_action: 3,
|
||||
whisper: 4,
|
||||
},
|
||||
trust_levels: {
|
||||
newuser: 0,
|
||||
basic: 1,
|
||||
member: 2,
|
||||
regular: 3,
|
||||
leader: 4,
|
||||
},
|
||||
groups: [
|
||||
{ id: 0, name: "everyone" },
|
||||
{ id: 1, name: "admins" },
|
||||
@@ -535,28 +542,6 @@ export default {
|
||||
is_custom_flag: true,
|
||||
},
|
||||
],
|
||||
trust_levels: [
|
||||
{
|
||||
id: 0,
|
||||
name: "new user",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: "basic user",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "member",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "regular",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "leader",
|
||||
},
|
||||
],
|
||||
archetypes: [
|
||||
{
|
||||
id: "regular",
|
||||
|
||||
@@ -16,6 +16,13 @@ PreloadStore.store("site", {
|
||||
moved_post: 10,
|
||||
},
|
||||
post_types: { regular: 1, moderator_action: 2 },
|
||||
trust_levels: {
|
||||
newuser: 0,
|
||||
basic: 1,
|
||||
member: 2,
|
||||
regular: 3,
|
||||
leader: 4,
|
||||
},
|
||||
groups: [
|
||||
{ id: 0, name: "everyone" },
|
||||
{ id: 1, name: "admins" },
|
||||
@@ -349,12 +356,5 @@ PreloadStore.store("site", {
|
||||
is_custom_flag: true,
|
||||
},
|
||||
],
|
||||
trust_levels: [
|
||||
{ id: 0, name: "new user" },
|
||||
{ id: 1, name: "basic user" },
|
||||
{ id: 2, name: "member" },
|
||||
{ id: 3, name: "regular" },
|
||||
{ id: 4, name: "leader" },
|
||||
],
|
||||
archetypes: [{ id: "regular", name: "Regular Topic", options: [] }],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user