mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: i18n: fix serialize
This commit is contained in:
1 parent
e1228345b0
commit
4976f94ec0
3 files changed
+8
-5
No files matched your search
@@ -449,7 +449,7 @@ export interface DiscussionTailReplyDoc {
|
||||
content: string;
|
||||
ip: string;
|
||||
edited?: boolean;
|
||||
editor?:number;
|
||||
editor?: number;
|
||||
}
|
||||
|
||||
export interface BlogDoc {
|
||||
@@ -736,7 +736,7 @@ export interface HydroGlobal {
|
||||
error: typeof import('./error');
|
||||
Logger: typeof import('./logger').Logger;
|
||||
logger: typeof import('./logger').logger;
|
||||
locales: Record<string, Record<string, string>>;
|
||||
locales: Record<string, Record<string, string> | Record<symbol, Record<string, string>>>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -62,8 +62,11 @@ global.Hydro.locales = new Proxy(translations, {
|
||||
get(self, lang: string) {
|
||||
if (!self[lang]) return {};
|
||||
return new Proxy(self[lang], {
|
||||
get(s, key: string) {
|
||||
return app.i18n.get(key, lang);
|
||||
get(s, key) {
|
||||
if (typeof key === 'string') return app.i18n.get(key, lang);
|
||||
const result = {};
|
||||
for (let i = s.length - 1; i; i--) Object.assign(result, s[i]);
|
||||
return result;
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
@@ -152,7 +152,7 @@ class UiConstantsHandler extends ResourceHandler {
|
||||
class LanguageHandler extends ResourceHandler {
|
||||
async all({ lang }) {
|
||||
if (!global.Hydro.locales[lang]) lang = SystemModel.get('server.language');
|
||||
this.response.body = `window.LOCALES=${JSON.stringify(global.Hydro.locales[lang])};`;
|
||||
this.response.body = `window.LOCALES=${JSON.stringify(global.Hydro.locales[lang][Symbol.for('iterate')])};`;
|
||||
this.response.type = 'application/javascript';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user