original_string: private function copyFallbackTranslations($newLocale)
      {
          \DB::transaction(function () use ($newLocale) {
  
              $existingTranslations = Translation::get();
              $fallbackLanguage = Language::whereIsFallback(1)->first();
  
              if ($fallbackLanguage) {
                  $fallbackIsoCode = $fallbackLanguage->iso_code;
  
                  $fallbackTranslations = Translation::whereLocale($fallbackIsoCode)->get();
  
                  if ($fallbackTranslations) {
                      $copiedTranslationsWithNewLocale = $fallbackTranslations->map(function ($translation) use (
                          $newLocale
                      ) {
                          unset($translation->id);
                          $translation->locale = mb_strtolower($newLocale);
  
                          return $translation;
                      })->toArray();
  
                      $translationsToCreate = [];
  
                      foreach ($copiedTranslationsWithNewLocale as $translation) {
  
                          // Safety feature - dont create entry if it already exists
                          // This might happen if administrator creates new language, deletes it, and then creates again
                          $exists = $existingTranslations
                              ->where('group', $translation['group'])
                              ->where('key', $translation['key'])
                              ->where('locale', $translation['locale'])
                              ->first();
  
                          if (!$exists) {
                              $translationsToCreate[] = $translation;
                          }
                      }
  
                      foreach (array_chunk($translationsToCreate, 300) as $chunk) {
                          Translation::insert($chunk);
                      }
                  }
              }
          });
      }
code: private function copyFallbackTranslations($newLocale)
      {
          \DB::transaction(function () use ($newLocale) {
  
              $existingTranslations = Translation::get();
              $fallbackLanguage = Language::whereIsFallback(1)->first();
  
              if ($fallbackLanguage) {
                  $fallbackIsoCode = $fallbackLanguage->iso_code;
  
                  $fallbackTranslations = Translation::whereLocale($fallbackIsoCode)->get();
  
                  if ($fallbackTranslations) {
                      $copiedTranslationsWithNewLocale = $fallbackTranslations->map(function ($translation) use (
                          $newLocale
                      ) {
                          unset($translation->id);
                          $translation->locale = mb_strtolower($newLocale);
  
                          return $translation;
                      })->toArray();
  
                      $translationsToCreate = [];
  
                      foreach ($copiedTranslationsWithNewLocale as $translation) {
  
                          // Safety feature - dont create entry if it already exists
                          // This might happen if administrator creates new language, deletes it, and then creates again
                          $exists = $existingTranslations
                              ->where('group', $translation['group'])
                              ->where('key', $translation['key'])
                              ->where('locale', $translation['locale'])
                              ->first();
  
                          if (!$exists) {
                              $translationsToCreate[] = $translation;
                          }
                      }
  
                      foreach (array_chunk($translationsToCreate, 300) as $chunk) {
                          Translation::insert($chunk);
                      }
                  }
              }
          });
      }
code_tokens: private function copyFallbackTranslations ( $ newLocale ) { \ DB :: transaction ( function ( ) use ( $ newLocale ) { $ existingTranslations = Translation :: get ( ) ; $ fallbackLanguage = Language :: whereIsFallback ( 1 ) -> first ( ) ; if ( $ fallbackLanguage ) { $ fallbackIsoCode = $ fallbackLanguage -> iso_code ; $ fallbackTranslations = Translation :: whereLocale ( $ fallbackIsoCode ) -> get ( ) ; if ( $ fallbackTranslations ) { $ copiedTranslationsWithNewLocale = $ fallbackTranslations -> map ( function ( $ translation ) use ( $ newLocale ) { unset ( $ translation -> id ) ; $ translation -> locale = mb_strtolower ( $ newLocale ) ; return $ translation ; } ) -> toArray ( ) ; $ translationsToCreate = [ ] ; foreach ( $ copiedTranslationsWithNewLocale as $ translation ) { // Safety feature - dont create entry if it already exists // This might happen if administrator creates new language, deletes it, and then creates again $ exists = $ existingTranslations -> where ( 'group' , $ translation [ 'group' ] ) -> where ( 'key' , $ translation [ 'key' ] ) -> where ( 'locale' , $ translation [ 'locale' ] ) -> first ( ) ; if ( ! $ exists ) { $ translationsToCreate [ ] = $ translation ; } } foreach ( array_chunk ( $ translationsToCreate , 300 ) as $ chunk ) { Translation :: insert ( $ chunk ) ; } } } } ) ; }
docstring: Copies translations from fallback language to new language
  
  @param $newLocale
docstring_tokens: Copies translations from fallback language to new language