title: Conditional import or alternative in JavaScript (ReactJS WebApp)?
body: <p>I'm implementing internationalization for a ReactJS webapp. 
  How can I avoid loading all language files?</p>
  
  <pre><code>import ru from './ru';
  import en from './en';
  
  // next lines are not important for this question from here
  import locale from 'locale';
  const supported = new locale.Locales(["en", "ru"])
  
  let language = 'ru';
  
  const acceptableLanguages = {
      ru: ru,
      en: en,
  }
  if (typeof window !== 'undefined') {
      const browserLanguage = window.navigator.userLanguage || window.navigator.language;
      const locales = new locale.Locales(browserLanguage)
      language = locales.best(supported).code
  }
  
  // till here
  
  // and here i'm returning a static object, containing all language variables
  const chooseLang = () =&gt; {
      return acceptableLanguages[language];
  }
  const lang = chooseLang();
  
  export default lang;
  </code></pre>