public static function LoadFromFolder( string $folder, Locale $locale, bool $useNumericId = false )
   {

      $languageFolderBase = rtrim( $folder, '\\/' );
      if ( ! empty( $languageFolderBase ) ) { $languageFolderBase .= '/'; }

      $languageFile = $languageFolderBase . $locale->getLID() . '_' . $locale->getCID();
      if ( \strlen( $locale->getCharset() ) > 0 )
      {
         $languageFile .= '/' . $locale->getCharset() . '.php';
      }
      else
      {
         $languageFile .= '.php';
      }

      if ( ! \file_exists( $languageFile ) )
      {
         $languageFile = $languageFolderBase . $locale->getLID() . '_' . $locale->getCID() . '.php';
      }

      if ( ! \file_exists( $languageFile ) )
      {
         $languageFile = $languageFolderBase . $locale->getLID() . '.php';
      }

      if ( ! \file_exists( $languageFile ) )
      {
         return new ArraySource( $locale, $useNumericId, [ 'data' => [] ] );
      }

      return new ArraySource( $locale, $useNumericId, [ 'file' => $languageFile ] );

   }
public static function LoadFromFolder( string $folder, Locale $locale, bool $useNumericId = false )
   {

      $languageFolderBase = rtrim( $folder, '\\/' );
      if ( ! empty( $languageFolderBase ) ) { $languageFolderBase .= '/'; }

      $languageFile = $languageFolderBase . $locale->getLID() . '_' . $locale->getCID();
      if ( \strlen( $locale->getCharset() ) > 0 )
      {
         $languageFile .= '/' . $locale->getCharset() . '.php';
      }
      else
      {
         $languageFile .= '.php';
      }

      if ( ! \file_exists( $languageFile ) )
      {
         $languageFile = $languageFolderBase . $locale->getLID() . '_' . $locale->getCID() . '.php';
      }

      if ( ! \file_exists( $languageFile ) )
      {
         $languageFile = $languageFolderBase . $locale->getLID() . '.php';
      }

      if ( ! \file_exists( $languageFile ) )
      {
         return new ArraySource( $locale, $useNumericId, [ 'data' => [] ] );
      }

      return new ArraySource( $locale, $useNumericId, [ 'file' => $languageFile ] );

   }
public static function LoadFromFolder ( string $ folder , Locale $ locale , bool $ useNumericId = false ) { $ languageFolderBase = rtrim ( $ folder , '\\/' ) ; if ( ! empty ( $ languageFolderBase ) ) { $ languageFolderBase .= '/' ; } $ languageFile = $ languageFolderBase . $ locale -> getLID ( ) . '_' . $ locale -> getCID ( ) ; if ( \ strlen ( $ locale -> getCharset ( ) ) > 0 ) { $ languageFile .= '/' . $ locale -> getCharset ( ) . '.php' ; } else { $ languageFile .= '.php' ; } if ( ! \ file_exists ( $ languageFile ) ) { $ languageFile = $ languageFolderBase . $ locale -> getLID ( ) . '_' . $ locale -> getCID ( ) . '.php' ; } if ( ! \ file_exists ( $ languageFile ) ) { $ languageFile = $ languageFolderBase . $ locale -> getLID ( ) . '.php' ; } if ( ! \ file_exists ( $ languageFile ) ) { return new ArraySource ( $ locale , $ useNumericId , [ 'data' => [ ] ] ) ; } return new ArraySource ( $ locale , $ useNumericId , [ 'file' => $ languageFile ] ) ; }
Loads a translation array source from a specific folder that contains one or more locale depending PHP files.

E.G: if the defined $folder is '/var/www/example.com/translations' and the declared Locale is de_DE.UTF-8

it tries to use:

- /var/www/example.com/translations/de_DE.UTF-8.php
- /var/www/example.com/translations/de_DE.php
- /var/www/example.com/translations/de.php

The used file should be declared like for translations with numeric indicators

<code>
return [

// Simple translation as string (translation is not a part of a category)
1 => 'Übersetzter Text',

// Translation is an array (translation is not a part of a category because the category is empty)
2 => [ 'category' => '', 'text' => 'Anderer übersetzter Text' ],

// Translation is an array (translation is a part of the 'category name' category)
4 => [ 'category' => 'category name', 'text' => 'Anderer übersetzter Text' ],

// Translation is an array (translation is not a part of a category because no category is defined)
5 => [ 'text' => 'Anderer übersetzter Text' ],

// Translation will be ignored because the 'text' element not exists
6 => [ 'category' => 'category name', 'value' => 'Anderer übersetzter Text' ]

];
</code>

or for translations with string indicators:

<code>
return [

// Simple translation as string (translation is not a part of a category)
'Translated text' => 'Übersetzter Text',

// Translation is an array (translation is not a part of a category because the category is empty)
'Other translated text 1' => [ 'category' => '', 'text' => 'Anderer übersetzter Text 1' ],

// Translation is an array (translation is a part of the 'category name' category)
'Other translated text 2' => [ 'category' => 'category name', 'text' => 'Anderer übersetzter Text 2' ],

// Translation is an array (translation is not a part of a category because no category is defined)
'Other translated text 3' => [ 'text' => 'Anderer übersetzter Text 3' ],

// Translation will be ignored because the 'text' element not exists
'Other translated text 3' => [ 'category' => 'category name', 'value' => 'Anderer übersetzter Text 4' ]

];
</code>

@param string $folder
@param \Beluga\Translation\Locale $locale
@param bool $useNumericId
@return \Beluga\Translation\Source\ArraySource
Loads a translation array source from a specific folder that contains one or more locale depending PHP files .