S222em
S222em
Explore posts from servers
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
const client = new SapphireClient({
i18n: {
defaultNS: 'index', // Does not work
i18next: {
defaultNS: 'index' // Does work
}
});
const client = new SapphireClient({
i18n: {
defaultNS: 'index', // Does not work
i18next: {
defaultNS: 'index' // Does work
}
});
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
const { namespaces, languages } = await this.walkRootDirectory(this.languagesDirectory);
const userOptions = isFunction(this.options.i18next) ? this.options.i18next(namespaces, languages) : this.options.i18next;
const ignoreJSONStructure = userOptions?.ignoreJSONStructure ?? false;
const skipOnVariables = userOptions?.interpolation?.skipOnVariables ?? false;

i18next.use(Backend);
await i18next.init({
backend: this.backendOptions,
fallbackLng: this.options.defaultName ?? 'en-US',
initImmediate: false,
interpolation: {
escapeValue: false,
...userOptions?.interpolation,
skipOnVariables
},
load: 'all',
defaultNS: 'default',
ns: namespaces,
preload: languages,
...userOptions,
ignoreJSONStructure
});
const { namespaces, languages } = await this.walkRootDirectory(this.languagesDirectory);
const userOptions = isFunction(this.options.i18next) ? this.options.i18next(namespaces, languages) : this.options.i18next;
const ignoreJSONStructure = userOptions?.ignoreJSONStructure ?? false;
const skipOnVariables = userOptions?.interpolation?.skipOnVariables ?? false;

i18next.use(Backend);
await i18next.init({
backend: this.backendOptions,
fallbackLng: this.options.defaultName ?? 'en-US',
initImmediate: false,
interpolation: {
escapeValue: false,
...userOptions?.interpolation,
skipOnVariables
},
load: 'all',
defaultNS: 'default',
ns: namespaces,
preload: languages,
...userOptions,
ignoreJSONStructure
});
This is a piece of code from InternationalizationHandler.init(). It does not use the specified default NS in the options as typed. It does work if I provide them to the i18next option. defaultNS in this.options is ignored on i18next init. See example below
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
I found the issue
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
Key is still not found. I will debug it further later. Got to go
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
Okay the "src/**/*.json" made it work
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
I know, but only for JSON files that are imported directly from the code. It just ignores mine as I dont directly import them
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
Typescript. I compile to another directory.
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
i18n: {
i18next: {
returnObjects: true,
},
defaultLanguageDirectory: '/var/tictactoe/languages',
defaultNS: 'index',
fetchLanguage: async (context: InternationalizationContext) => {
const locale = context.interactionGuildLocale || context.interactionLocale;
if (locale && container.i18n.languages.has(locale)) return locale;

return 'en-US';
},
},
i18n: {
i18next: {
returnObjects: true,
},
defaultLanguageDirectory: '/var/tictactoe/languages',
defaultNS: 'index',
fetchLanguage: async (context: InternationalizationContext) => {
const locale = context.interactionGuildLocale || context.interactionLocale;
if (locale && container.i18n.languages.has(locale)) return locale;

return 'en-US';
},
},
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
Nevermind t(':key') does not work either
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
So how would I use the t function with defaultNS? Should it be like t(':key')? Im getting a not found on t('key')
24 replies
SIASapphire - Imagine a framework
Created by S222em on 12/19/2022 in #sapphire-support
i18next plugin without namespaces
Okay yeah thanks
24 replies