Skip to content

Commit

Permalink
Target the full variant instead of modern
Browse files Browse the repository at this point in the history
The packages ending in "-modern" are deprecated and will be dropped in v46.

https://cldr.unicode.org/index/downloads/cldr-45#h.q2akkekvprf2
  • Loading branch information
olvlvl committed Aug 9, 2024
1 parent 717b4fa commit dea0531
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
2 changes: 0 additions & 2 deletions generator/src/Command/GenerateLocaleId.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public function render(
namespace ICanBoogie\CLDR;
use InvalidArgumentException;
final class LocaleId
{
/**
Expand Down
3 changes: 1 addition & 2 deletions lib/GitHub/UrlResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ class UrlResolver
{
public const DEFAULT_ORIGIN = "https://raw.githubusercontent.com/unicode-org/cldr-json/";
public const DEFAULT_VERSION = "45.0.0";
public const DEFAULT_VARIATION = self::VARIATION_MODERN;
public const DEFAULT_VARIATION = self::VARIATION_FULL;

public const VARIATION_MODERN = 'modern';
public const VARIATION_FULL = 'full';

/**
Expand Down
22 changes: 11 additions & 11 deletions lib/LocaleId.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

namespace ICanBoogie\CLDR;

use InvalidArgumentException;

final class LocaleId
{
/**
* Whether a locale ID is available.
*
* @param string $value
* A locale identifier; for example, fr-BE
*/
public static function is_available(string $value): bool
{
Expand All @@ -25,6 +26,9 @@ public static function is_available(string $value): bool
}

/**
* @param string $value
* A locale identifier; for example, fr-BE
*
* @throws LocaleNotAvailable
*/
public static function assert_is_available(string $value): void
Expand All @@ -33,31 +37,27 @@ public static function assert_is_available(string $value): void
or throw new LocaleNotAvailable($value);
}

/**
* @var array<string, self>
* Where _key_ is a locale identifier.
*/
private static array $instances = [];

/**
* Returns a {@see LocaleId} of a value.
*
* Note: If the locale has a parent locale, that locale is used instead.
*
* @param string $value
* A locale identifier.
* A locale identifier; for example, fr-BE
*
* @throws InvalidArgumentException if the locale is not available.
* @throws LocaleNotAvailable
*/
public static function of(string $value): self
{
static $instances;

self::assert_is_available($value);

if (isset(self::PARENT_LOCALES[$value])) {
$value = self::PARENT_LOCALES[$value];
}

return self::$instances[$value] ??= new self($value);
return $instances[$value] ??= new self($value);
}

private function __construct(
Expand Down
22 changes: 11 additions & 11 deletions tests/GitHub/UrlResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public static function provide_resolve(): array

"annotations-derived/{locale}/annotations" => [
"annotations-derived/fr-CA/annotations",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-derived-modern/annotationsDerived/fr-CA/annotations.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-derived-full/annotationsDerived/fr-CA/annotations.json"
],

"annotations/{locale}/annotations" => [
"annotations/hi-Latn/annotations",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-modern/annotations/hi-Latn/annotations.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-full/annotations/hi-Latn/annotations.json"
],

"bcp47/calendar" => [
Expand All @@ -44,7 +44,7 @@ public static function provide_resolve(): array

"cal-buddhist/{locale}/ca-buddhist" => [
"cal-buddhist/de-BE/ca-buddhist",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-cal-buddhist-modern/main/de-BE/ca-buddhist.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-cal-buddhist-full/main/de-BE/ca-buddhist.json"
],

"core/supplemental/plurals" => [
Expand All @@ -64,32 +64,32 @@ public static function provide_resolve(): array

"dates/{locale}/ca-gregorian" => [
"dates/ko-KP/ca-gregorian",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-modern/main/ko-KP/ca-gregorian.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-full/main/ko-KP/ca-gregorian.json"
],

"dates/{locale}/dateFields" => [
"dates/ko-KP/dateFields",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-modern/main/ko-KP/dateFields.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-full/main/ko-KP/dateFields.json"
],

"localnames/{locale}/languages" => [
"localenames/fr-MA/languages",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-localenames-modern/main/fr-MA/languages.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-localenames-full/main/fr-MA/languages.json"
],

"misc/{locale}/listPatterns" => [
"misc/ms-SG/listPatterns",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-misc-modern/main/ms-SG/listPatterns.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-misc-full/main/ms-SG/listPatterns.json"
],

"numbers/{locale}/currencies" => [
"numbers/en-150/currencies",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-modern/main/en-150/currencies.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-full/main/en-150/currencies.json"
],

"numbers/{locale}/numbers" => [
"numbers/en-150/numbers",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-modern/main/en-150/numbers.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-full/main/en-150/numbers.json"
],

"rbnf/{language}" => [
Expand All @@ -99,12 +99,12 @@ public static function provide_resolve(): array

"segments/{language}/suppressions" => [
"segments/de/suppressions",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-segments-modern/segments/de/suppressions.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-segments-full/segments/de/suppressions.json"
],

"units/{locale}/units" => [
"units/pt-MO/units",
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-units-modern/main/pt-MO/units.json"
"https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-units-full/main/pt-MO/units.json"
],

];
Expand Down

0 comments on commit dea0531

Please sign in to comment.