From 47d0d2782062fec06dbcdf9d5997e6544a471552 Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Fri, 17 Jun 2022 15:44:54 +0800 Subject: [PATCH] build --- lib/aspects/locales.d.ts | 10 ++++++++++ lib/aspects/locales.js | 38 ++++++++++++++++++++++++++++++++++++++ lib/features/locales.d.ts | 13 +++++++++++++ lib/features/locales.js | 13 +++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 lib/aspects/locales.d.ts create mode 100644 lib/aspects/locales.js create mode 100644 lib/features/locales.d.ts create mode 100644 lib/features/locales.js diff --git a/lib/aspects/locales.d.ts b/lib/aspects/locales.d.ts new file mode 100644 index 00000000..4cbd259e --- /dev/null +++ b/lib/aspects/locales.d.ts @@ -0,0 +1,10 @@ +export declare function getTranslations(options: { + namespace: string | string[]; + locale: string; +}): { + common: { + action: { + confirm: string; + }; + }; +}; diff --git a/lib/aspects/locales.js b/lib/aspects/locales.js new file mode 100644 index 00000000..99027135 --- /dev/null +++ b/lib/aspects/locales.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getTranslations = void 0; +function getTranslations(options) { + const { namespace, locale } = options; + // 表示entity locale表示zh_CN + let translations = {}; + return { + common: { + action: { + confirm: '确定2', + }, + }, + }; + // const getTranslations = (ns: string) => { + // const entityName = ns.substring(0, 1).toUpperCase() + ns.substring(1); + // const entityName2 = ns.toLowerCase(); + // try { + // const data = require(`${entityName}/locales/${locale}.ts`).default; + // assign(translations, { + // [entityName2]: data, + // }); + // } + // catch (err) { + // throw err + // } + // }; + // if (namespace instanceof Array) { + // namespace.forEach((ns) => { + // getTranslations(ns); + // }) + // } + // else { + // getTranslations(namespace); + // } + // return translations; +} +exports.getTranslations = getTranslations; diff --git a/lib/features/locales.d.ts b/lib/features/locales.d.ts new file mode 100644 index 00000000..d7ec74e7 --- /dev/null +++ b/lib/features/locales.d.ts @@ -0,0 +1,13 @@ +import { EntityDict, Aspect, Context } from 'oak-domain/lib/types'; +import { Feature } from '../types/Feature'; +export declare class Locales extends Feature, Record>>> { + get(namespace: string | string[], locale: string, scene: string): Promise<{ + translations: { + common: { + action: { + confirm: string; + }; + }; + }; + }>; +} diff --git a/lib/features/locales.js b/lib/features/locales.js new file mode 100644 index 00000000..e6b40c78 --- /dev/null +++ b/lib/features/locales.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Locales = void 0; +const Feature_1 = require("../types/Feature"); +class Locales extends Feature_1.Feature { + async get(namespace, locale, scene) { + const translations = await this.getAspectProxy().getTranslations({ namespace, locale }, scene); + return { + translations, + }; + } +} +exports.Locales = Locales;