Skip to content

Commit

Permalink
Add i18n to spoiler option (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSpicyBurrito authored Aug 30, 2024
1 parent af35654 commit b2b98d4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/clients/i18n/commonText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type CommonTextI18n = {
rarity: string
attribute: string
card: string
spoilerContent: string
}

export const fetchCommonText = fetchI18n<CommonTextI18n>('/common.json')
15 changes: 0 additions & 15 deletions src/sonolus/configuration.ts

This file was deleted.

6 changes: 6 additions & 0 deletions src/sonolus/configuration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Repository } from '../../repository/index.js'
import { updateConfigurationOptions } from './option.js'

export const updateConfiguration = (repository: Repository) => {
updateConfigurationOptions(repository)
}
15 changes: 15 additions & 0 deletions src/sonolus/configuration/option.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ServerOptionsModel } from '@sonolus/express'
import { Repository } from '../../repository/index.js'

export const configurationOptions = {
spoilers: {
name: {},
required: false,
type: 'toggle',
def: false,
},
} satisfies ServerOptionsModel

export const updateConfigurationOptions = (repository: Repository) => {
configurationOptions.spoilers.name = repository.commonTexts.spoilerContent
}
6 changes: 4 additions & 2 deletions src/sonolus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { config } from '../config.js'
import { Repository } from '../repository/index.js'
import { installBackground, updateBackground } from './background/index.js'
import { backgroundSearches } from './background/search.js'
import { serverOptions } from './configuration.js'
import { updateConfiguration } from './configuration/index.js'
import { configurationOptions } from './configuration/option.js'
import { installEngine } from './engine/index.js'
import { installInfo } from './info/index.js'
import { installLevel, updateLevel } from './level/index.js'
Expand All @@ -27,7 +28,7 @@ export const sonolus = new Sonolus({
searches: backgroundSearches,
},
configuration: {
options: serverOptions,
options: configurationOptions,
},
})

Expand All @@ -40,6 +41,7 @@ installBackground()
installEngine()

export const updateSonolus = (repository: Repository) => {
updateConfiguration(repository)
updateLevel(repository)
updatePlaylist(repository)
updateBackground(repository)
Expand Down

0 comments on commit b2b98d4

Please sign in to comment.