mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 17:57:24 +08:00
DEV: Improve error messages for legacy theme helpers in gjs (#29191)
theme-setting and theme-i18n are not needed in `.gjs` files. This commit adds more helpful error messages to direct developers to the modern alternatives.
This commit is contained in:
parent
492cf52bab
commit
182689b6bb
|
@ -3,5 +3,12 @@ import I18n from "discourse-i18n";
|
|||
|
||||
registerRawHelper("theme-i18n", themeI18n);
|
||||
export default function themeI18n(themeId, key, params) {
|
||||
if (typeof themeId !== "number") {
|
||||
throw new Error(
|
||||
`The theme-i18n helper is not supported in this context.\n\n` +
|
||||
`In a theme .gjs file, use '{{i18n (themePrefix "${themeId}")}}' instead.\n\n` +
|
||||
`'themePrefix' is available automatically, and does not need to be imported.\n`
|
||||
);
|
||||
}
|
||||
return I18n.t(`theme_translations.${themeId}.${key}`, params);
|
||||
}
|
||||
|
|
|
@ -3,5 +3,12 @@ import { registerRawHelper } from "discourse-common/lib/helpers";
|
|||
|
||||
registerRawHelper("theme-setting", themeSetting);
|
||||
export default function themeSetting(themeId, key) {
|
||||
if (typeof themeId !== "number") {
|
||||
throw new Error(
|
||||
`The theme-setting helper is not supported in this context.\n\n` +
|
||||
`In a theme .gjs file, use '{{settings.${themeId}}}' instead.\n\n` +
|
||||
`'settings' is available automatically, and does not need to be imported.\n`
|
||||
);
|
||||
}
|
||||
return getThemeSetting(themeId, key);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user