Created
June 16, 2023 18:02
-
-
Save dev-sampsonorson/6471fc8f8e18d95faab67071317d5119 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const language = detectVisitorLanguage(); | |
// - import(someVariable) is not supported; it must be a constant | |
// - Some path must be specified | |
// - We can specify a directory or set of files | |
// - Everything that could be requested (potentially match that path) is included (in the bundle during build time) | |
// https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import | |
import(`./locale/${language}.json`).then((module) => { | |
// do something with the translation | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment