Title: Translation files for JavaScript?
Last modified: August 30, 2016

---

# Translation files for JavaScript?

 *  [David Gewirtz](https://wordpress.org/support/users/dgewirtz/)
 * (@dgewirtz)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/translation-files-for-javascript/)
 * I’ve made my plugin translation ready and have four translations provided by 
   users, but they don’t appear to be picking up strings in JavaScript. Is there
   a best practice to enable translators to translate WordPress JavaScript elements?
 * Thanks!
 * –David

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/translation-files-for-javascript/#post-6774044)
 * Oh! Good question!
 * I don’t have such a good answer 🙁
    The only thing I’ve seen is the suggestion
   to use [wp_localize_script()](http://codex.wordpress.org/Function_Reference/wp_localize_script),
   which is fine to a point. If your JS has extensive translation needs, passing
   every string through this way can get tedious. If this technique starts to appear
   onerous, I think a dynamic JS file could work. This is a PHP file that outputs
   JS instead of HTML, so you can use the familiar i18n functions to deal with translating
   strings. Properly setting this up is a bit tricky.
 * There appears to be a more formal dynamic JS framework used in core code, though
   I can’t find an example right now. I see it on occasion, but I don’t know anymore
   about it, sorry.
 *  [Jay](https://wordpress.org/support/users/phyrax/)
 * (@phyrax)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/translation-files-for-javascript/#post-6774161)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) – Would you be referring
   to BackBoneJS which is what manages the media popups and such? I’ve yet to fully
   understand BackBone but from what I DO understand is it is sort of an MVC framework
   for JavaScript whereas most of your ‘templating’ you do in HTML and PHP.
 * Idk if that would fit your scenario David and it’s got a learning curve, but 
   from my perspective, if I have a large JavaScript project BackBone would be the
   way to go.
 * If it’s not a huge project localize_script will be the way to go. Some fairly
   large libraries use it already, it’s just a matter of discipline to put together
   the array.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/translation-files-for-javascript/#post-6774195)
 * BackboneJS – Yes, that’s it! Thanks Jerry.
 * Thinking a bit more about this, if the only issue is translating JS strings, 
   even with a large project, passing them through localize script wouldn’t be a
   big problem as long as you use logic to only localize strings that might actually
   be used on the page. Passing every possible string of a project amounting into
   the hundreds wouldn’t be good, but how many strings could any particular page
   use?
 * I’m now inclined to believe anyone working on a project too big for `wp_localize_script()`
   wouldn’t have much use for any of my feeble advice 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Translation files for JavaScript?’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/translation-files-for-javascript/#post-6774195)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
