Skip to content

Commit

Permalink
feat(config): better case handling
Browse files Browse the repository at this point in the history
- allow use of uppercase, lowercase and keep.
rename `useUppercaseConversionForValues` to `caseFormat`
  • Loading branch information
Nyameliaaaa committed Feb 25, 2023
1 parent 96f4849 commit 4dec8f8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ setConfig({
getLocalizedString: ({ namespace, string, lang, options }) => {
return i18nLib.getString({ namespace, string, lang, options }) ?? 'fetch_fail';
},
useUppercaseConversionValues: false,
caseFormat: 'lowercase', // can be lowercase, uppercase or keep.
seperatorChar: '.',
validators: proccess.ENV.NODE_ENV === 'production',
langs: i18nLib.langs, // using discord lang codes is required.
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConfigType } from 'types';

let config: ConfigType = {
getLocalizedString: ({ string }) => `function_not_implemented_${string.toLocaleLowerCase()}`,
useUppercaseConversionForValues: false,
caseFormat: 'lowercase',
seperatorChar: '.',
validators: true,
langs: ['en-US'],
Expand All @@ -21,7 +21,7 @@ let config: ConfigType = {
getLocalizedString: ({ namespace, string, lang, options }) => {
return client.i18n.getString({ namespace, string, lang, options }) ?? 'fetch_fail'
},
useUppercaseConversionValues: false,
caseFormat: 'lowercase',
seperatorChar: '_',
validators: proccess.ENV.NODE_ENV === 'production',
langs: client.i18n.langs , // use discord i18n codes
Expand Down
5 changes: 3 additions & 2 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ export interface ConfigType {
getLocalizedString: (options: GetLocalizedStringOptions) => string;

/**
* Whether to uppercase the values of Select Menu Options & Option Choices when fetching the string.
* The case your strings are coded in.
* If you are using camelCase key names, you must use 'keep'
* @defaultValue `false`
*/
useUppercaseConversionForValues: boolean;
caseFormat: 'uppercase' | 'lowercase' | 'keep';

/**
* The char to join the base keys with.
Expand Down

0 comments on commit 4dec8f8

Please sign in to comment.