forked from umpirsky/country-list
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
36 lines (30 loc) · 1.03 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env php
<?php
/**
* This file is part of the Country List project.
*
* (c) Саша Стаменковић <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Dumps country list to all formats in all languages.
*/
require_once __DIR__ . '/autoload.php';
use Symfony\Component\Locale\Locale;
use Symfony\Component\Filesystem\Filesystem;
use Umpirsky\Country\Dumper\Iterator;
$locale = new Locale();
$filesystem = new Filesystem();
$dumperIterator = new Iterator();
$filesystem->mkdir($rootDir = sprintf('%s/country', __DIR__));
foreach ($locale->getLocales() as $language) {
$filesystem->mkdir($dir = sprintf('%s/%s', $rootDir, $language));
$countries = $locale->getDisplayCountries($language);
foreach($dumperIterator as $dumper) {
$file = sprintf('%s/country.%s', $dir, $dumper->getFormat());
$filesystem->touch($file);
file_put_contents($file, $dumper->dump($countries));
}
}