title: How can update a Laravel language file with a function or a query?
body: <p><em>Hello, I created a Helper function for the laravel localization which store the translates in the Database. and also the function get the translate from the Database. this is the function.</em></p>
  
  <pre><code>public static function translate($word,$locale) {
      $find_word = DB::table('translate')-&gt;where('word', $word);
      if($find_word-&gt;count() &gt; 0){
          if(count(DB::table('languages')-&gt;where('field_name',$locale)-&gt;get()) == 0){
              $locale = 'en';
          }
          if($find_word-&gt;first()-&gt;$locale !== null  &amp;&amp; $find_word-&gt;first()-&gt;$locale !== ''){
              $return = $find_word-&gt;first()-&gt;$locale;
          }
          else{
              $return = $find_word-&gt;first()-&gt;en;
          }
      }
      else{
          $data['word'] = $word;
          $data['en'] = str_replace('_', ' ', $word);
          DB::table('translate')-&gt;insert($data);
          $return = str_replace('_', ' ', $word);
          $locale = 'en';
      }
      return $return;
  }
  </code></pre>
  
  <p><em>The function works correctly but for every word I need to run a Database query. So its better to create such function to save the words in a file not to the database. when I call the function and request a word and the word does not exists add the word to the file. I prefer this function from laravel default localization. because in the Laravel localization we must create a file manually then we must add words and its translate to the file manually.</em></p>
  
  <p>So, How can I create such function to save the new requested word in a file or get it from the file?</p>