From ed36814ec985b99a24a6174164dcbe05e1f89dec Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:39:44 -0500 Subject: [PATCH] update docs for localizer and pubsliher --- packages/localizer/index.mdx | 6 +++--- packages/localizer/index.ts | 6 +++--- packages/publisher/index.ts | 21 ++++++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/localizer/index.mdx b/packages/localizer/index.mdx index 500aeba..0c3f3ad 100644 --- a/packages/localizer/index.mdx +++ b/packages/localizer/index.mdx @@ -34,7 +34,7 @@ import { Tabs, TabItem } from "@astrojs/starlight/components"; - ```json title=~/assets/locals/es.json + ```json title=~/assets/locals/es-ES.json { "salute": { "hello": "hola" @@ -62,7 +62,7 @@ execute : (ctx, { deps }) => { //the localizer object from makeDependencies deps.localizer // Returns the Spanish translation for 'salute.hello' - deps.localizer.translate("salute.hello", "es"); + deps.localizer.translate("salute.hello", "es-ES"); } ``` @@ -71,5 +71,5 @@ execute : (ctx, { deps }) => { import { local } from '@sern/localizer'; // Returns the Spanish translation for 'salute.hello' -const greeting = local('salute.hello', 'es'); +const greeting = local('salute.hello', 'es-ES'); ``` diff --git a/packages/localizer/index.ts b/packages/localizer/index.ts index a926c7d..02c0ee3 100644 --- a/packages/localizer/index.ts +++ b/packages/localizer/index.ts @@ -54,10 +54,10 @@ class ShrimpleLocalizer implements Init { * Note: this method only works AFTER your container has been initiated * @example * ```ts - * assert.deepEqual(locals("salute.hello", "es"), "hola") + * assert.deepEqual(locals("salute.hello", "es-ES"), "hola") * ``` */ -export const local = (i: string, local: string) => { +export const local = (i: string, local: string) => { return Service('localizer').translate(i, local) } @@ -68,7 +68,7 @@ export const local = (i: string, local: string) => { * An init plugin to add localization fields to a command module. * Your localization configuration should look like, * @param root {string} If you have conflicting command names, you may configure the root of the name. (= command/{root}) - * Below is es.json (spanish) + * Below is es-ES.json (spanish) * ```json { "command/comer" : { diff --git a/packages/publisher/index.ts b/packages/publisher/index.ts index 4a5726d..48677cb 100644 --- a/packages/publisher/index.ts +++ b/packages/publisher/index.ts @@ -40,14 +40,11 @@ const serializePermissions = (permissions: unknown) => { const BASE_URL = new URL('https://discord.com/api/v10/applications/'); const PUBLISHABLE = 0b1110; -const GUILD_IDS = Symbol.for('GUILD_IDS') const PUBLISH = Symbol.for('@sern/publish') export class Publisher implements Init { - constructor( - private modules: Map, - private sernEmitter : Emitter, - private logger: Logging - ) {} + constructor(private modules: Map, + private sernEmitter : Emitter, + private logger: Logging) {} async init() { if(!process.env.DISCORD_TOKEN) { @@ -168,7 +165,9 @@ export class Publisher implements Init { } } } - + this.logger.info({ + message: "Result of publishing is located at .sern/command-data-remote.json.\n Do not remove this!" + }); await writeFile( '.sern/command-data-remote.json', JSON.stringify({ global: globalJsonBody, @@ -199,9 +198,13 @@ export type ValidPublishOptions = | PublishConfig | ((absPath: string, module: CommandModule) => PublishConfig) - +/** + * the publishConfig plugin. + * If your commandModule requires extra properties such as publishing for certain guilds, you would + * put those options in there. + * @param {ValidPublishOptions} config options to configure how this module is published + */ export const publishConfig = (config: ValidPublishOptions) => { - return CommandInitPlugin(({ module, absPath }) => { if((module.type & PUBLISHABLE) === 0) { //@ts-ignore