Skip to content

Instantly share code, notes, and snippets.

@ebeloded
Created February 17, 2022 21:18
Show Gist options
  • Save ebeloded/df8c72faa9b59f37ca6aebf69f2c0c5b to your computer and use it in GitHub Desktop.
Save ebeloded/df8c72faa9b59f37ca6aebf69f2c0c5b to your computer and use it in GitHub Desktop.
dynamically load languages
Object.entries(import.meta.glob('../locales/*.yaml'))
.map(([path, f]) => [/locales\/(.+?)\.yaml/.exec(path)?.[1], f] as any)
.forEach(([key, f]) => {
console.log({ key, f })
locales[key] = true
if (key !== 'en') register(key, f)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment