Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(locale): get current language from config (fixes #84)
- Loading branch information
Showing
11 changed files
with
80 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ locale: | |
load: load | ||
quit: quit | ||
save: save | ||
current: en |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Container, LogLevel, Module, NullLogger } from 'noicejs'; | ||
|
||
import { ConfigFile } from '../src/model/file/Config'; | ||
import { INJECT_CONFIG, INJECT_LOGGER } from '../src/module'; | ||
|
||
export function getTestLogger() { | ||
// TODO: return console/bunyan logger if TEST_LOGGER=that | ||
return NullLogger.global; | ||
} | ||
|
||
export function getTestConfig(): ConfigFile { | ||
return { | ||
logger: { | ||
level: LogLevel.DEBUG, | ||
name: 'test', | ||
streams: [], | ||
}, | ||
locale: { | ||
bundles: {}, | ||
current: 'en', | ||
}, | ||
}; | ||
} | ||
|
||
export async function getTestContainer(...modules: Array<Module>): Promise<Container> { | ||
const config = getTestConfig(); | ||
const logger = getTestLogger(); | ||
|
||
modules[0].bind(INJECT_CONFIG).toInstance(config); | ||
modules[0].bind(INJECT_LOGGER).toInstance(logger); | ||
|
||
const container = Container.from(...modules); | ||
await container.configure({ | ||
logger, | ||
}); | ||
|
||
return container; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters