This will depend on your build environment. We have a webpack-plugin that will simplify this for you.
https://github.com/Esri/arcgis-webpack-plugin
// webpack.config.js
module.exports = {
...
plugins: [
new ArcGISPlugin({
locales: ['en', 'es']
})
]
...
}
If you're not using webpack, or don't want to use the plugin (the asset copy/filter functionality is all it really offers in most cases) you can mimic what the plugin does in your own application.
This is how it will filter the the locale files in the copy operation.
https://github.com/Esri/arcgis-webpack-plugin/blob/master/lib/requiredPlugins.js#L50-L73