Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Sep 16, 2016
1 parent bf284f9 commit 0ddd8bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions lib/Provider/WebProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public function provide($key)

if ($http_code != 200)
{
echo $url;

throw new ResourceNotFound($key);
}

Expand Down Expand Up @@ -142,55 +144,63 @@ private function resolve_url($key)
$repository = "cldr-dates";
}

return "$repository{$this->prefer}/{$this->version}/main/$locale/ca-$calendar";
return "$repository{$this->prefer}/main/$locale/ca-$calendar";

}, $key);

$key = preg_replace_callback(self::REGEX_SUPPLEMENTAL, function ($matches) {

list(, $which) = $matches;

return "cldr-core/{$this->version}/supplemental/$which";
return "cldr-core/supplemental/$which";

}, $key);

$key = preg_replace_callback(self::REGEX_NUMBERS_OR_CURRENCIES, function ($matches) {

list(, $locale, $which) = $matches;

return "cldr-numbers{$this->prefer}/{$this->version}/main/$locale/$which";
return "cldr-numbers{$this->prefer}/main/$locale/$which";

}, $key);

$key = preg_replace_callback(self::REGEX_CLDR_MISC, function ($matches) {

list(, $locale, $which) = $matches;

return "cldr-misc{$this->prefer}/{$this->version}/main/$locale/$which";
return "cldr-misc{$this->prefer}/main/$locale/$which";

}, $key);

$key = preg_replace_callback(self::REGEX_CLDR_DATES, function ($matches) {

list(, $locale, $which) = $matches;

return "cldr-dates{$this->prefer}/{$this->version}/main/$locale/$which";
return "cldr-dates{$this->prefer}/main/$locale/$which";

}, $key);

$key = preg_replace_callback(self::REGEX_CLDR_LOCALENAMES, function ($matches) {

list(, $locale, $which) = $matches;

return "cldr-localenames{$this->prefer}/{$this->version}/main/$locale/$which";
return "cldr-localenames{$this->prefer}/main/$locale/$which";

}, $key);

$key = preg_replace_callback(self::REGEX_CLDR_UNITS, function ($matches) {

list(, $locale, $which) = $matches;

return "cldr-units{$this->prefer}/{$this->version}/main/$locale/$which";
return "cldr-units{$this->prefer}/main/$locale/$which";

}, $key);

# insert version

$key = preg_replace_callback('#^([^/]+)#', function ($matches) {

return "{$matches[1]}/{$this->version}";

}, $key);

Expand Down
2 changes: 1 addition & 1 deletion tests/LocalizedCurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function test_get_symbol()

public function test_localize()
{
$localized = self::$currency->localize('en-US');
$localized = self::$currency->localize('en');
$this->assertInstanceOf(LocalizedCurrency::class, $localized);
$this->assertEquals("Irish Pound", $localized->name);
}
Expand Down

0 comments on commit 0ddd8bc

Please sign in to comment.