mirror of
https://github.com/sern-handler/tools
synced 2026-06-06 01:16:59 +00:00
update docs for localizer and pubsliher
This commit is contained in:
@@ -34,7 +34,7 @@ import { Tabs, TabItem } from "@astrojs/starlight/components";
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Spanish">
|
||||
```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');
|
||||
```
|
||||
|
||||
@@ -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" : {
|
||||
|
||||
@@ -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<string, CommandModule>,
|
||||
private sernEmitter : Emitter,
|
||||
private logger: Logging
|
||||
) {}
|
||||
constructor(private modules: Map<string, CommandModule>,
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user