Skip to content

Commit dbf30b0

Browse files
committed
refactor(i18n): replace LocaleString with Locale type for consistency
1 parent ed44dc8 commit dbf30b0

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/arguments/language.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { LanguageKeys } from '#lib/i18n/languageKeys';
22
import { Argument } from '@sapphire/framework';
3-
import type { LocaleString } from 'discord.js';
3+
import type { Locale } from 'discord.js';
44

5-
export class UserArgument extends Argument<LocaleString> {
5+
export class UserArgument extends Argument<Locale> {
66
public run(parameter: string, context: Argument.Context) {
77
const { languages } = this.container.i18n;
8-
if (languages.has(parameter)) return this.ok(parameter as LocaleString);
8+
if (languages.has(parameter)) return this.ok(parameter as Locale);
99
return this.error({ parameter, identifier: LanguageKeys.Arguments.Language, context: { ...context, possibles: [...languages.keys()] } });
1010
}
1111
}

src/lib/i18n/translate.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DecoratorIdentifiers } from '@sapphire/decorators';
44
import { Identifiers, container } from '@sapphire/framework';
55
import type { InternationalizationContext, TFunction } from '@sapphire/plugin-i18next';
66
import type { Nullish } from '@sapphire/utilities';
7-
import type { Interaction, LocaleString } from 'discord.js';
7+
import type { Interaction, Locale } from 'discord.js';
88

99
export function translate(identifier: string): string {
1010
switch (identifier) {
@@ -120,11 +120,11 @@ export function resolveT(t: TResolvable): TFunction {
120120
* @param locale The locale to get the translation function for.
121121
* @returns The translation function for the specified locale.
122122
*/
123-
export function getT(locale?: LocaleString | string | Nullish) {
123+
export function getT(locale?: Locale | string | Nullish) {
124124
return container.i18n.getT(locale ?? 'en-US');
125125
}
126126

127-
export function getSupportedLanguageName(interaction: Interaction): LocaleString {
127+
export function getSupportedLanguageName(interaction: Interaction): Locale {
128128
if (interaction.guildLocale && container.i18n.languages.has(interaction.guildLocale)) return interaction.guildLocale;
129129
return 'en-US';
130130
}
@@ -133,7 +133,7 @@ export function getSupportedLanguageT(interaction: Interaction): TFunction {
133133
return getT(getSupportedLanguageName(interaction));
134134
}
135135

136-
export function getSupportedUserLanguageName(interaction: Interaction): LocaleString {
136+
export function getSupportedUserLanguageName(interaction: Interaction): Locale {
137137
if (container.i18n.languages.has(interaction.locale)) return interaction.locale;
138138
return getSupportedLanguageName(interaction);
139139
}
@@ -146,10 +146,10 @@ export function getSupportedUserLanguageT(interaction: Interaction): TFunction {
146146
* Fetches the language for the given {@link InternationalizationContext}.
147147
* If the language cannot be fetched, defaults to 'en-US'.
148148
* @param context The InternationalizationContext to fetch the language for.
149-
* @returns The fetched language as a {@link LocaleString}.
149+
* @returns The fetched language as a {@link Locale}.
150150
*/
151151
export async function fetchLanguage(context: InternationalizationContext) {
152-
return (await container.i18n.fetchLanguage(context))! as LocaleString;
152+
return (await container.i18n.fetchLanguage(context))! as Locale;
153153
}
154154

155155
/**

0 commit comments

Comments
 (0)