Xinax\LaravelGettext\FileSystem::generateLocales PHP Method

generateLocales() public method

Creates the localization directories and files by domain
public generateLocales ( ) : array
return array
    public function generateLocales()
    {
        // Application base path
        if (!file_exists($this->getDomainPath())) {
            $this->createDirectory($this->getDomainPath());
        }
        $localePaths = [];
        // Locale directories
        foreach ($this->configuration->getSupportedLocales() as $locale) {
            $localePath = $this->getDomainPath($locale);
            if (!file_exists($localePath)) {
                // Locale directory is created
                $this->addLocale($localePath, $locale);
                array_push($localePaths, $localePath);
            }
        }
        return $localePaths;
    }

Usage Example

 /**
  * Test the update 
  */
 public function testFileSystem()
 {
     // Domain path test
     $domainPath = $this->fileSystem->getDomainPath();
     // Locale path test
     $locale = 'es_AR';
     $localePath = $this->fileSystem->getDomainPath($locale);
     // Create locale test
     $localesGenerated = $this->fileSystem->generateLocales();
     $this->assertTrue($this->fileSystem->checkDirectoryStructure(true));
     $this->assertCount(3, $localesGenerated);
     $this->assertTrue(is_dir($domainPath));
     $this->assertTrue(strpos($domainPath, 'i18n') !== false);
     foreach ($localesGenerated as $localeGenerated) {
         $this->assertTrue(file_exists($localeGenerated));
     }
     $this->assertTrue(is_dir($localePath));
     // Update locale test
     $this->assertTrue($this->fileSystem->updateLocale($localePath, $locale, "backend"));
 }