-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cdruc
committed
Mar 26, 2021
0 parents
commit 56bd8be
Showing
26 changed files
with
767 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.github export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
/.editorconfig export-ignore | ||
/.php_cs.dist export-ignore | ||
/psalm.xml export-ignore | ||
/psalm.xml.dist export-ignore | ||
/testbench.yaml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: cdruc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: Ask a question | ||
url: https://github.com/cdruc/laravel-langscanner/discussions/new?category=q-a | ||
about: Ask the community for help | ||
- name: Request a feature | ||
url: https://github.com/cdruc/laravel-langscanner/discussions/new?category=ideas | ||
about: Share ideas for new features | ||
- name: Report a bug | ||
url: https://github.com/cdruc/laravel-langscanner/issues/new | ||
about: Report a reproducable bug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Security Policy | ||
|
||
If you discover any security related issues, please email druc@pinsmile.com instead of using the issue tracker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.idea | ||
.php_cs | ||
.php_cs.cache | ||
.phpunit.result.cache | ||
build | ||
composer.lock | ||
coverage | ||
docs | ||
phpunit.xml | ||
psalm.xml | ||
testbench.yaml | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
All notable changes to `laravel-langscanner` will be documented in this file. | ||
|
||
## 1.0.0 - 202X-XX-XX | ||
|
||
- initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) cdruc <druc@pinsmile.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# laravel-langscanner | ||
|
||
[](https://packagist.org/packages/cdruc/laravel-langscanner) | ||
[](https://packagist.org/packages/cdruc/laravel-langscanner) | ||
|
||
## Usage | ||
|
||
Scan your project for missing translations: | ||
|
||
``` | ||
php artisan langscanner | ||
``` | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require cdruc/laravel-langscanner | ||
``` | ||
|
||
## Credits | ||
|
||
This package is based on [joedixon/laravel-translation](https://github.com/joedixon/laravel-translation) and [themsaid/laravel-langman-gui](https://github.com/themsaid/laravel-langman-gui) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "cdruc/laravel-langscanner", | ||
"description": "Scan missing language translations.", | ||
"keywords": [ | ||
"cdruc", | ||
"laravel-langscanner" | ||
], | ||
"homepage": "https://github.com/cdruc/laravel-langscanner", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Constantin Druc", | ||
"email": "druc@pinsmile.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.4|^8.0", | ||
"spatie/laravel-package-tools": "^1.4.3", | ||
"illuminate/contracts": "^8.0", | ||
"illuminate/support": "^8.0", | ||
"illuminate/filesystem": "^8.0", | ||
"ext-json": "*" | ||
}, | ||
"require-dev": { | ||
"nunomaduro/collision": "^5.3", | ||
"orchestra/testbench": "^6.15", | ||
"phpunit/phpunit": "^9.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Cdruc\\Langscanner\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Cdruc\\Langscanner\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "./vendor/bin/testbench package:test", | ||
"test-coverage": "vendor/bin/phpunit --coverage-html coverage" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Cdruc\\Langscanner\\LangscannerServiceProvider" | ||
] | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Translation methods | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Which methods to look for when scanning translations. | ||
| | ||
*/ | ||
'translation_methods' => [ | ||
'__', | ||
'trans', | ||
'trans_choice', | ||
'@lang', | ||
'Lang::get', | ||
'Lang::choice', | ||
'Lang::trans', | ||
'Lang::transChoice', | ||
'@choice' | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Scan paths | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Which directories to scan for missing translations. | ||
| | ||
*/ | ||
'scan_paths' => [app_path(), resource_path()], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Scan excluded paths | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Which directories to exclude when scanning for missing translations. | ||
| | ||
*/ | ||
'scan_excluded_paths' => [], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Excluded languages | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Which languages to exclude when scanning for missing translations. | ||
| | ||
*/ | ||
'excluded_languages' => ['en'], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
executionOrder="random" | ||
failOnWarning="true" | ||
failOnRisky="true" | ||
failOnEmptyTestSuite="true" | ||
beStrictAboutOutputDuringTests="true" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Cdruc Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
<report> | ||
<html outputDirectory="build/coverage"/> | ||
<text outputFile="build/coverage.txt"/> | ||
<clover outputFile="build/logs/clover.xml"/> | ||
</report> | ||
</coverage> | ||
<logging> | ||
<junit outputFile="build/report.junit.xml"/> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Cdruc\Langscanner\Commands; | ||
|
||
use Cdruc\Langscanner\Langscanner; | ||
use Illuminate\Console\Command; | ||
|
||
class LangscannerCommand extends Command | ||
{ | ||
protected Langscanner $langscanner; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'langscanner'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'List all translation keys which don\'t have a corresponding translation'; | ||
|
||
public function __construct(Langscanner $langscanner) | ||
{ | ||
parent::__construct(); | ||
$this->langscanner = $langscanner; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | ||
*/ | ||
public function handle() | ||
{ | ||
$missingTranslations = $this->langscanner->missingTranslations(); | ||
|
||
if (empty($missingTranslations)) { | ||
return $this->info("No missing translations were detected."); | ||
} | ||
|
||
$rows = []; | ||
|
||
// set some headers for the table of results | ||
$headers = ["Language", "Type", "Group", "Key"]; | ||
|
||
// iterate over each of the missing languages | ||
foreach ($missingTranslations as $language => $types) { | ||
// iterate over each of the file types (json or array) | ||
foreach ($types as $type => $keys) { | ||
// iterate over each of the keys | ||
foreach ($keys as $key => $value) { | ||
// populate the array with the relevant data to fill the table | ||
foreach ($value as $k => $v) { | ||
$rows[] = [$language, $type, $key, $k]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// render the table of results | ||
$this->table($headers, $rows); | ||
} | ||
} |
Oops, something went wrong.