How to add parameter to wp_enqueue_script?

Shortcodes are inconvenient for such things, because they are processed in content, way after site’s header. However since you don’t need to deal with styles, only a script, it’s a little easier by moving stuff to footer.

Your logic would be something like following:

  1. Locale shortcode stores requested locale in some way.
  2. At some point between content and footer you register and enqueue scripts, making locale script dependency of main script.
  3. WP reaches footer, resolved enqueued scripts, and prints them out for you.

tech