title: Dictionary of words and their translation in JavaScript
body: <p>Consider the simple following HTML code:</p>
  
  <pre><code>&lt;input id="dict_field" type="text"/&gt;
  &lt;button id="translate_btn" type="button" class="btn"&gt;translate&lt;/button&gt;
  </code></pre>
  
  <p>The user inputs something and clicking the button triggers a function that returns a translation.</p>
  
  <p>And the JQuery code:</p>
  
  <pre><code>$(document).ready(function(){
  
    $('#translate_btn').click(function(){
      var word = $('#dict_field').val();
      var translation = "";
      translation = translate(word (, dictionary?));
      // For simplicity for now just display the result in the same input field
      $('#dict_field').val(translation)
    });
  
  });
  
  // pseudo code. How to implement this and build the dictionary I need?
  
  function translate(word (, dictionary?)){
    if word in dictionary.keys() -&gt; return dictionary[word]
    else return "no such word in dict"
  }
  </code></pre>
  
  <p>Given the following:</p>
  
  <ol>
  <li>The translation needs only to be one way (key to value).</li>
  <li>The dictionary is custom made (meaning I have to build it, I cannot count on external API such as Google's).</li>
  <li>I estimate the size of the dictionary keys could be of the order of thousands, say between 1 and 5000.</li>
  <li>Not sure if related but eventually I'd like the translation to happen in real time (as soon as the user finishes the input without need of a button click). This for now is secondary.</li>
  </ol>
  
  <p>What is a good way, "objectively", to build a map/dictionary {key:value} to implement a translation function/API? Any detail can be considered, such as speed, scalability, cost etc., keeping in view my above requirements.</p>
  
  <p>I've little experience with this kind of things, but I have some thoughts, such as:</p>
  
  <ol>
  <li>Use a very long js file containing the dictionary (might not be a good idea)</li>
  <li>Store everything in a text file and read from there</li>
  <li>Look at some database (but won't that be overkill?)</li>
  </ol>
  
  <p>Appreciate valuable suggestions. Thanks for any help.</p>