Skip to content

Commit

Permalink
add optional lng option
Browse files Browse the repository at this point in the history
  • Loading branch information
Chr1s70ph committed Dec 12, 2021
1 parent 8e6929b commit 9bc4237
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions types/customTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,27 @@ export class DiscordClient extends Client {
}

/**
* Translates {@link key} using {@link i18next.t}
* @param {string} key Key to look translation for
* @param {Object} options Options
* Translate {@link trans.key} using {@link trans.lng} or alternatively {@link trans.options}.
* @param {trans} args Arguments to use to translate
* @returns {string}
*/
public translate(key: string | string[], options?: object | string): string {
return i18next.t(key, options)
public translate(args: trans): string {
const options = args.options ?? args.lng ? { lng: args.lng } : null
return i18next.t(args.key, options)
}
}

/**
* Interface for translation parameters
* @readonly
* @private
*/
interface trans {
key: string | string[]
lng?: string
options?: object | string
}

/**
* Interface of Command structure
* @readonly
Expand Down

0 comments on commit 9bc4237

Please sign in to comment.