diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a7c44dd --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..886475c --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ba21f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +.idea +.php_cs +.php_cs.cache +.phpunit.result.cache +build +composer.lock +coverage +docs +phpunit.xml +psalm.xml +testbench.yaml +vendor +node_modules diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..c7d380c --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,43 @@ +notPath('bootstrap/*') + ->notPath('storage/*') + ->notPath('resources/view/mail/*') + ->in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline_array' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'method', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d60ffd3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to `laravel-portugal/locale` will be documented in this file. + +## 1.0.0 - 2021-04-26 + +- initial release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..bab2766 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) laravel-portugal + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..094627d --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Resources lang em Português + +[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-portugal/locale.svg?style=flat-square)](https://packagist.org/packages/laravel-portugal/locale) +[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/laravel-portugal/locale/run-tests?label=tests)](https://github.com/laravel-portugal/locale/actions?query=workflow%3Arun-tests+branch%3Amaster) +[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/laravel-portugal/locale/Check%20&%20fix%20styling?label=code%20style)](https://github.com/laravel-portugal/locale/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster) +[![Total Downloads](https://img.shields.io/packagist/dt/laravel-portugal/locale.svg?style=flat-square)](https://packagist.org/packages/laravel-portugal/locale) + +In this repository, you can find the Portuguese lang files for your Laravel project. + +## Installation + +You can install the package via composer: + +```bash +composer require laravel-portugal/locale +``` + +You can publish and run the migrations with: + +```bash +php artisan vendor:publish --provider="LaravelPortugal\Locale\LocaleServiceProvider" +``` + +You can publish the config file with: + +```bash +php artisan vendor:publish --provider="LaravelPortugal\Locale\LocaleServiceProvider" --tag="locale-config" +``` + +## Usage + +After the language publish you need to change the default language of your application in the `config/app.php` configuration by setting `locale` to `pt`. + +Then just use it normally. + +```php +trans('passwords.reset'); // A sua senha foi alterada! + +__('password.throttled') // Aguarde antes de tentar novamente. +``` + +## Testing + +```bash +composer test +``` + +## Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. + +## Credits + +- [Caneco](https://github.com/caneco) +- [All Contributors](../../contributors) + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..5f8c347 --- /dev/null +++ b/composer.json @@ -0,0 +1,52 @@ +{ + "name": "laravel-portugal/locale", + "description": "Resources lang em Português", + "keywords": ["laravel-portugal", "laravel", "locale", "lang", "language", "localization"], + "homepage": "https://github.com/laravel-portugal/locale", + "license": "MIT", + "authors": [ + { + "name": "Caneco", + "email": "caneco@me.com", + "role": "Developer" + } + ], + "require": { + "php": "^8.0", + "illuminate/contracts": "^8.0" + }, + "require-dev": { + "larapack/dd": "^1.1", + "orchestra/testbench": "^6.17", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.4" + }, + "autoload": { + "psr-4": { + "LaravelPortugal\\Locale\\": "src", + "LaravelPortugal\\Locale\\Database\\Factories\\": "database/factories" + } + }, + "autoload-dev": { + "psr-4": { + "LaravelPortugal\\Locale\\Tests\\": "tests" + } + }, + "scripts": { + "psalm": "vendor/bin/psalm", + "test": "./vendor/bin/testbench package:test --no-coverage", + "test-coverage": "vendor/bin/phpunit --coverage-html coverage" + }, + "config": { + "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "LaravelPortugal\\Locale\\LocaleServiceProvider" + ] + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..7405e16 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,39 @@ + + + + + tests + + + + + ./src + + + + + + + + + + + diff --git a/psalm.xml.dist b/psalm.xml.dist new file mode 100644 index 0000000..c6df33e --- /dev/null +++ b/psalm.xml.dist @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/resources/lang/pt/auth.php b/resources/lang/pt/auth.php new file mode 100755 index 0000000..be80cd7 --- /dev/null +++ b/resources/lang/pt/auth.php @@ -0,0 +1,19 @@ + 'As credenciais indicadas não coincidem com as registadas no sistema.', + 'password' => 'A password indicada está incorreta.', + 'throttle' => 'O número limite de tentativas de login foi atingido. Por favor tente novamente dentro de :seconds segundos.', +]; diff --git a/resources/lang/pt/pagination.php b/resources/lang/pt/pagination.php new file mode 100755 index 0000000..c2fde3d --- /dev/null +++ b/resources/lang/pt/pagination.php @@ -0,0 +1,19 @@ + '« Anterior', + 'next' => 'Próximo »', + +]; diff --git a/resources/lang/pt/passwords.php b/resources/lang/pt/passwords.php new file mode 100755 index 0000000..7aa436d --- /dev/null +++ b/resources/lang/pt/passwords.php @@ -0,0 +1,22 @@ + 'A sua senha foi alterada!', + 'sent' => 'Foi enviado um link por email para alterar a sua password!', + 'throttled' => 'Aguarde antes de tentar novamente.', + 'token' => 'Esse token de alteração de password é inválido.', + 'user' => "Não encontramos nenhum utilizador com esse endereço de email.", + +]; diff --git a/resources/lang/pt/validation.php b/resources/lang/pt/validation.php new file mode 100755 index 0000000..3b3dd25 --- /dev/null +++ b/resources/lang/pt/validation.php @@ -0,0 +1,155 @@ + 'O campo :attribute deve ser aceite.', + 'active_url' => 'O campo :attribute não é um URL válido.', + 'after' => 'O campo :attribute deve ser uma data depois :date.', + 'after_or_equal' => 'O campo :attribute deve ser uma data posterior ou igual a :date.', + 'alpha' => 'O campo :attribute só pode conter letras.', + 'alpha_dash' => 'O campo :attribute só pode conter letras, números e traços.', + 'alpha_num' => 'O campo :attribute só pode conter letras e números.', + 'array' => 'O campo :attribute deve ser uma matriz.', + 'before' => 'O campo :attribute deve ser uma data anterior :date.', + 'before_or_equal' => 'O campo :attribute deve ser uma data anterior ou igual a :date.', + 'between' => [ + 'numeric' => 'O campo :attribute deve ser entre :min e :max.', + 'file' => 'O campo :attribute deve ser entre :min e :max kilobytes.', + 'string' => 'O campo :attribute deve ser entre :min e :max caracteres.', + 'array' => 'O campo :attribute deve ter entre :min e :max itens.', + ], + 'boolean' => 'O campo :attribute deve ser verdadeiro ou falso.', + 'confirmed' => 'O campo :attribute de confirmação não é valido.', + 'date' => 'O campo :attribute não é uma data válida.', + 'date_equals' => 'O campo :attribute deve ser igual à data :date.', + 'date_format' => 'O campo :attribute não corresponde ao formato :format.', + 'different' => 'Os campos :attribute e :other devem ser diferentes.', + 'digits' => 'O campo :attribute deve ter :digits dígitos.', + 'digits_between' => 'O campo :attribute deve ter entre :min e :max dígitos.', + 'dimensions' => 'O campo :attribute tem dimensões de imagem inválidas.', + 'distinct' => 'O campo :attribute campo tem um valor repetido.', + 'email' => 'O campo :attribute deve ser um endereço de email válido.', + 'ends_with' => 'O campo :attribute deve terminar com um dos seguintes valores: :values.', + 'exists' => 'O campo :attribute selecionado é inválido.', + 'file' => 'O campo :attribute deve ser um ficheiro.', + 'filled' => 'O campo :attribute o campo deve ter um valor.', + 'gt' => [ + 'numeric' => 'O campo :attribute deve ser maior que :value.', + 'file' => 'O campo :attribute deve ser maior que :value kilobytes.', + 'string' => 'O campo :attribute deve ser maior que :value characters.', + 'array' => 'O campo :attribute deve conter mais que :value items.', + ], + 'gte' => [ + 'numeric' => 'O campo :attribute deve ser maior ou igual a :value.', + 'file' => 'O campo :attribute deve ser maior ou igual a :value kilobytes.', + 'string' => 'O campo :attribute deve ser maior ou igual a :value characters.', + 'array' => 'O campo :attribute deve conter :value items ou mais.', + ], + 'image' => 'O campo :attribute deve ser uma imagem.', + 'in' => 'O campo :attribute selecionado é inválido.', + 'in_array' => 'O campo :attribute não existe em :other.', + 'integer' => 'O campo :attribute deve ser um número inteiro.', + 'ip' => 'O campo :attribute deve ser um endereço de IP válido.', + 'ipv4' => 'O campo :attribute deve ser um endereço IPv4 válido.', + 'ipv6' => 'O campo :attribute deve ser um endereço IPv6 válido.', + 'json' => 'O campo :attribute deve ser uma string JSON válida.', + 'lt' => [ + 'numeric' => 'O campo :attribute deve ser menor que :value.', + 'file' => 'O campo :attribute deve ser menor que :value kilobytes.', + 'string' => 'O campo :attribute deve ser menor que :value characters.', + 'array' => 'O campo :attribute não deve conter menos que :value items.', + ], + 'lte' => [ + 'numeric' => 'O campo :attribute deve ser menor ou igual a :value.', + 'file' => 'O campo :attribute deve ser menor ou igual a :value kilobytes.', + 'string' => 'O campo :attribute deve ser menor ou igual a :value characters.', + 'array' => 'O campo :attribute não deve conter mais que :value items.', + ], + 'max' => [ + 'numeric' => 'O campo :attribute não pode ser superior a :max.', + 'file' => 'O campo :attribute não pode ser superior a :max kilobytes.', + 'string' => 'O campo :attribute não pode ser superior a :max caracteres.', + 'array' => 'O campo :attribute não pode ter mais do que :max itens.', + ], + 'mimes' => 'O campo :attribute deve ser um ficheiro de tipo: :values.', + 'mimetypes' => 'O campo :attribute deve ser um ficheiro de tipo: :values.', + 'min' => [ + 'numeric' => 'O campo :attribute deve ser pelo menos :min.', + 'file' => 'O campo :attribute deve ter pelo menos :min kilobytes.', + 'string' => 'O campo :attribute deve ter pelo menos :min caracteres.', + 'array' => 'O campo :attribute deve ter pelo menos :min itens.', + ], + 'multiple_of' => 'O campo :attribute deve ser um multiplo de :value.', + 'not_in' => 'O campo :attribute selecionado é inválido.', + 'not_regex' => 'O formato do campo :attribute é inválido.', + 'numeric' => 'O campo :attribute deve ser um número.', + 'password' => 'A password está incorrecta.', + 'present' => 'O campo :attribute deve estar presente.', + 'regex' => 'O campo :attribute tem um formato inválido.', + 'required' => 'O campo :attribute é obrigatório.', + 'required_if' => 'O campo :attribute é obrigatório quando :other é :value.', + 'required_unless' => 'O campo :attribute é obrigatório exceto quando :other seja :values.', + 'required_with' => 'O campo :attribute é obrigatório quando :values está presente.', + 'required_with_all' => 'O campo :attribute é obrigatório quando :values está presente.', + 'required_without' => 'O campo :attribute é obrigatório quando :values não está presente.', + 'required_without_all' => 'O campo :attribute é obrigatório quando nenhum dos :values estão presentes.', + 'prohibited' => 'O campo :attribute é proibido.', + 'prohibited_if' => 'O campo :attribute é proibido quando o :other é :value.', + 'prohibited_unless' => 'O campo :attribute é proibido se o :other não é :values.', + 'same' => 'Os campos :attribute e :other devem corresponder.', + 'size' => [ + 'numeric' => 'O campo :attribute deve ser :size.', + 'file' => 'O campo :attribute deve ser :size kilobytes.', + 'string' => 'O campo :attribute deve ser :size caracteres.', + 'array' => 'O campo :attribute deve conter :size itens.', + ], + 'starts_with' => 'O campo :attribute deve iniciar com um dos seguintes valores: :values.', + 'string' => 'O campo :attribute deve ser uma string.', + 'timezone' => 'O campo :attribute deve ser uma zona válida.', + 'unique' => 'O campo :attribute já está sendo utilizado.', + 'uploaded' => 'O campo :attribute falha no upload.', + 'url' => 'O campo :attribute tem um formato inválido.', + 'uuid' => 'O campo :attribute deve ser um UUID válido.', + + /* + |-------------------------------------------------------------------------- + | Traduções de validação alternativas + |-------------------------------------------------------------------------- + | + | Aqui pode especificar mensagens de validação para alguns atributos + | utilizando a convenção "attribute.rule". Tornando-se fácil a + | validação de alguns campos numa regra particular. + | + */ + + 'custom' => [ + 'attribute.name' => [ + 'rule-name' => 'mensagem-alternativa', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Nomes de atributos alternativos + |-------------------------------------------------------------------------- + | + | Aqui poderá ser definido quais os :atributos de poderão ser alterados + | na mensagem de forma a facilitar a comunição do erro ao utilizador. + | Um exemplo válido será "E-mail" invés de "email". + | + */ + + 'attributes' => [], + +]; diff --git a/src/LocaleServiceProvider.php b/src/LocaleServiceProvider.php new file mode 100644 index 0000000..4fd82d2 --- /dev/null +++ b/src/LocaleServiceProvider.php @@ -0,0 +1,20 @@ +app->runningInConsole()) { + $this->registerPublishing(); + } + } + + private function registerPublishing() + { + $this->publishes([__DIR__.'/../resources/lang/pt' => resource_path('lang/pt')], 'lang-pt'); + } +} diff --git a/tests/Unit/LocaleTest.php b/tests/Unit/LocaleTest.php new file mode 100644 index 0000000..772bd09 --- /dev/null +++ b/tests/Unit/LocaleTest.php @@ -0,0 +1,17 @@ +assertFileExists(__DIR__.'/../../resources/lang/pt/auth.php'); + $this->assertFileExists(__DIR__.'/../../resources/lang/pt/pagination.php'); + $this->assertFileExists(__DIR__.'/../../resources/lang/pt/passwords.php'); + $this->assertFileExists(__DIR__.'/../../resources/lang/pt/validation.php'); + } +}