You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*Publish translations for multiple languages (comma-separated):
21
+
```bash
22
+
php artisan nova-lang:publish de,ru
23
+
```
24
24
25
-
Publish translations for all languages:
26
-
```bash
27
-
php artisan nova-lang:publish --all
28
-
```
25
+
*Publish translations for all available languages:
26
+
```bash
27
+
php artisan nova-lang:publish --all
28
+
```
29
29
30
-
Publish translations and override existing files:
31
-
```bash
32
-
php artisan nova-lang:publish de,ru --force
33
-
```
30
+
* Publish translations and override existing files:
31
+
```bash
32
+
php artisan nova-lang:publish de,ru --force
33
+
```
34
+
35
+
#### Aliases
36
+
The language codes chosen for the files in this repository may not match the preferences for your project. You can use the `‑‑alias` option to publish locales using a different filename.
37
+
38
+
* Publish translations for one language with an alias, using the simple format `{alias}`:
39
+
```bash
40
+
php artisan nova-lang:publish de --alias=de-DE
41
+
```
42
+
This will publish the file `de-DE.json`.
43
+
44
+
* Publish translations for multiple languages with multiple aliases, using the format `{locale}:{alias}` (comma-separated):
You do not need to supply an alias for every locale that is to be published, only those that you wish to override.
56
+
57
+
* Here are some example aliases for common use cases:
58
+
59
+
* Use Chinese with scripts instead of regions: `zh-CN:zh-Hans,zh-TW:zh-Hant`
60
+
* Default to Brazilian Portuguese over European: `pt:pt-PT,pt-BR:pt`
61
+
* Default to Serbian in Latin script over Cyrillic: `sr-Latn:sr,sr:sr-Cyrl`
62
+
63
+
64
+
* There is also an `‑‑underscore` or `‑U` switch to publish locales with an underscore separator instead of a hyphen. This can be used in combination with aliases.
34
65
35
66
### Development Commands (debug mode only)
36
67
@@ -42,12 +73,12 @@ This command is to assist contributors to find any untranslated keys for their c
42
73
43
74
A stub JSON file will be created at `storage_path('app/nova-lang/missing/{locale}.json')`. You can copy those keys into the `resources/lang/{locale}.json` language file in your own fork of the repository, translate them and create a pull request.
44
75
45
-
Output missing translation keys for one or more languages:
76
+
*Output missing translation keys for one or more languages:
46
77
```bash
47
78
php artisan nova-lang:missing de,ru
48
79
```
49
80
50
-
Output missing translation keys for all languages:
81
+
*Output missing translation keys for all languages:
51
82
```bash
52
83
php artisan nova-lang:missing --all
53
84
```
@@ -58,7 +89,7 @@ This command is to assist maintainers to update the completeness of each languag
58
89
59
90
A `README.excerpt.md` and `contributors.json` file will be created at `storage_path('app/nova-lang')`. You can copy those files into your own fork of the repository and create a pull request.
60
91
61
-
Output list of languages, lines translated and contributors:
92
+
*Output list of languages, lines translated and contributors:
Copy file name to clipboardExpand all lines: src/Commands/NovaLangPublish.php
+102-9Lines changed: 102 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,12 @@
9
9
10
10
class NovaLangPublish extends Command
11
11
{
12
+
/**
13
+
* Possible locale separators.
14
+
* @var string
15
+
*/
16
+
constSEPARATORS = '-‑_';
17
+
12
18
/**
13
19
* The name and signature of the console command.
14
20
*
@@ -17,6 +23,8 @@ class NovaLangPublish extends Command
17
23
protected$signature = 'nova-lang:publish
18
24
{locales? : Comma-separated list of languages}
19
25
{--all : Publish all languages}
26
+
{--alias= : Publish files using a different filename for certain locales, in the format "locale:alias,..."}
27
+
{--U|underscore : Use underscore instead of dash as locale separator }
20
28
{--force : Override existing files}';
21
29
22
30
/**
@@ -59,23 +67,33 @@ public function handle()
59
67
return;
60
68
}
61
69
62
-
$requestedLocales->each(function (string$locale) use ($availableLocales) {
70
+
$requestedLocales->each(function (string$alias, string$locale) use ($availableLocales) {
63
71
64
-
if ($locale == 'en' && $this->isForce()) {
65
-
if (!$this->confirm(sprintf('Are you sure you want to republish translations for [en] locale? This will overwrite the latest file from laravel/nova.'))) {
72
+
if ($alias == 'en' && $this->isForce()) {
73
+
if (!$this->confirm(sprintf('Are you sure you want to publish translations for [en] locale? This will overwrite the file from laravel/nova.'))) {
66
74
return;
67
75
}
68
76
}
69
77
70
78
if (! $availableLocales->contains($locale)) {
71
-
$this->error(sprintf('Unfortunately, translations for [%s] locale don\'t exist. Feel free to send a PR to add them and help other people :)', $locale));
79
+
$this->warn(sprintf('Unfortunately, translations for [%s] locale don\'t exist. Feel free to send a PR to add them and help other people.', $locale));
0 commit comments