Skip to content

Commit

Permalink
Merge pull request #9 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Fixed root package error
  • Loading branch information
andrey-helldar authored Nov 10, 2023
2 parents b87ed49 + e835c44 commit 4e5c30b
Show file tree
Hide file tree
Showing 89 changed files with 102 additions and 110 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.github/ export-ignore

bin/ export-ignore
tests/ export-ignore

.editorconfig export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
IS_DIRTY=1
vendor/bin/lang sync
php app/combined.php
php bin/combined.php
{ git add . && git commit -a -m "🔑 Synchronization of translation keys"; } || IS_DIRTY=0
Expand Down
7 changes: 4 additions & 3 deletions app/combined.php → bin/combined.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
declare(strict_types=1);

use DragonCode\Support\Facades\Filesystem\File;
use LaravelLang\Locales\Enums\Locale;
use LaravelLang\NativeLocaleNames\Helpers\Arr;
use LaravelLang\NativeLocaleNames\Native;

require_once __DIR__ . '/../vendor/autoload.php';

$result = [];

foreach (Locale::values() as $locale) {
$locales = Arr::file(__DIR__ . '/../source/locales.json');

foreach (array_keys($locales) as $locale) {
$result[$locale] = Native::get($locale)[$locale];
}

File::store(
__DIR__ . '/../locales/_combined/php.json',
__DIR__ . '/../locales/_combined/json.json',
json_encode(Arr::ksort($result), JSON_UNESCAPED_UNICODE ^ JSON_UNESCAPED_SLASHES ^ JSON_PRETTY_PRINT)
);
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"dragon-code/support": "^6.11",
"laravel-lang/locales": "^1.0"
"dragon-code/support": "^6.11"
},
"require-dev": {
"laravel-lang/locales": "^1.6",
"laravel-lang/status-generator": "^2.3.1",
"pestphp/pest": "^2.24.3",
"symfony/var-dumper": "^6.3"
Expand Down
2 changes: 1 addition & 1 deletion locales/_combined/php.json → locales/_combined/json.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
"zh_CN": "简体中文)",
"zh_HK": "中文(香港)",
"zh_TW": "中文(台灣)"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions source/locales.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"af": "Afrikaans",
"ar": "Arabic",
"az": "Azerbaijani (Latin)",
"be": "Belarusian",
"bg": "Bulgarian",
"bn": "Bengali",
"bs": "Bosnian",
"ca": "Catalan",
"cs": "Czech",
"cy": "Welsh",
"da": "Danish",
"de": "German",
"de_CH": "Swiss High German",
"el": "Greek",
"en": "English",
"es": "Spanish",
"et": "Estonian",
"eu": "Basque",
"fa": "Persian",
"fi": "Finnish",
"fil": "Filipino",
"fr": "French",
"gl": "Galician",
"gu": "Gujarati",
"he": "Hebrew",
"hi": "Hindi",
"hr": "Croatian",
"hu": "Hungarian",
"hy": "Armenian",
"id": "Indonesian",
"is": "Icelandic",
"it": "Italian",
"ja": "Japanese",
"ka": "Georgian",
"kk": "Kazakh",
"km": "Khmer",
"kn": "Kannada",
"ko": "Korean",
"lt": "Lithuanian",
"lv": "Latvian",
"mk": "Macedonian",
"mn": "Mongolian",
"mr": "Marathi",
"ms": "Malay",
"nb": "Norwegian Bokmål",
"ne": "Nepali",
"nl": "Dutch",
"nn": "Norwegian Nynorsk",
"oc": "Occitan",
"pl": "Polish",
"ps": "Pashto",
"pt": "Portuguese",
"pt_BR": "Brazilian Portuguese",
"ro": "Romanian",
"ru": "Russian",
"sc": "Sardinian",
"si": "Sinhala",
"sk": "Slovak",
"sl": "Slovene",
"sq": "Albanian",
"sr_Cyrl": "Serbian (Cyrillic)",
"sr_Latn": "Serbian (Latin)",
"sr_Latn_ME": "Serbian (Montenegro)",
"sv": "Swedish",
"sw": "Swahili",
"tg": "Tajik (Cyrillic)",
"th": "Thai",
"tk": "Turkmen",
"tl": "Tagalog",
"tr": "Turkish",
"ug": "Uyghur",
"uk": "Ukrainian",
"ur": "Urdu",
"uz_Cyrl": "Uzbek (Cyrillic)",
"uz_Latn": "Uzbek (Latin)",
"vi": "Vietnamese",
"zh_CN": "Chinese (Simplified)",
"zh_HK": "Chinese (Hong Kong)",
"zh_TW": "Chinese (Taiwan)"
}
100 changes: 0 additions & 100 deletions source/locales.php

This file was deleted.

7 changes: 6 additions & 1 deletion src/Helpers/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Path
{
public static function resolve(string $locale): bool|string
{
return realpath(__DIR__ . '/../../locales/' . $locale . '/php.json');
return realpath(__DIR__ . '/../../locales/' . $locale . '/json.json');
}

public static function exists(string $locale): bool
{
return static::resolve($locale) !== false;
}
}
6 changes: 5 additions & 1 deletion src/Native.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ protected static function locale(Locale|string|null $locale): ?string
return null;
}

return $locale->value ?? Locale::tryFrom($locale)?->value;
if (class_exists(Locale::class) && $locale instanceof Locale) {
return $locale->value;
}

return Path::exists($locale) ? $locale : null;
}
}
2 changes: 1 addition & 1 deletion tests/Helpers/native.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

function sourceLocale(string $locale): array
{
return Arr::file(__DIR__ . '/../../locales/' . $locale . '/php.json');
return Arr::file(__DIR__ . '/../../locales/' . $locale . '/json.json');
}

0 comments on commit 4e5c30b

Please sign in to comment.