Skip to content

Commit

Permalink
Merge pull request #1 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
First Release
  • Loading branch information
andrey-helldar authored Jun 9, 2024
2 parents 52bb2a4 + 4755742 commit 40de5a6
Show file tree
Hide file tree
Showing 34 changed files with 1,795 additions and 19 deletions.
804 changes: 804 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto

.github/ export-ignore
tests/ export-ignore

.editorconfig export-ignore
.env.example export-ignore
.gitattributes export-ignore
.gitignore export-ignore

phpunit.xml export-ignore
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Bug Report
url: https://github.com/Laravel-Lang/common/issues/new?assignees=andrey-helldar&labels=bug%2Croutes&template=bug_report.yml&title=%5BBug%5D%3A+&environment-package-name=laravel-lang%2Froutes
about: Report a bug or other issue
- name: Feature Request
url: https://github.com/Laravel-Lang/common/issues/new?labels=feature%2Croutes&projects=&template=feature_request.yml
about: Propose a new feature
- name: Questions & Other
url: https://github.com/Laravel-Lang/common/discussions
about: 'If you want to ask about something else, use the discussions.'
- name: Laravel Issue
url: https://github.com/laravel/framework/issues
about: 'If you have a question about your Laravel implementation, ask it in your Laravel project.'
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
labels:
- dependabot
15 changes: 15 additions & 0 deletions .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Close Stale Issues and PRs

on:
schedule:
- cron: 34 0 * * *
workflow_dispatch:

permissions:
issues: write
pull-requests: write

jobs:
stale:
name: Close Stale
uses: Laravel-Lang/.github/.github/workflows/close-stale-issues.yml@main
10 changes: 10 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Code Style

on: [ push, pull_request ]

permissions: write-all

jobs:
style:
name: Code Style
uses: TheDragonCode/.github/.github/workflows/code-style.yml@main
23 changes: 23 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Documentation

on:
push:
branches:
- main

permissions: write-all

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Generate docs trigger
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.COMPOSER_TOKEN }}
repo: Laravel-Lang/docs
type: docs
17 changes: 17 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release Drafter

on:
push:
branches:
- main
release:
types:
- published
- unpublished
- released
- prereleased
workflow_dispatch:

jobs:
Update:
uses: Laravel-Lang/.github/.github/workflows/release-drafter.yml@main
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on:
push:
branches-ignore:
- 'projects/**'
pull_request:
branches-ignore:
- 'projects/**'

permissions: read-all

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ "8.2", "8.3" ]
laravel: [ "10.0", "11.0" ]

name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv
coverage: xdebug
env:
COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }}

- name: Install dependencies
run: composer require laravel/framework:^${{ matrix.laravel }}

- name: Execute tests
run: composer test
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.idea/
vendor/

.cache
.DS_Store
.env
.php_cs.cache
.phpintel
.temp

*.bak
*.cache
*.clover
*.orig

composer.lock
38 changes: 19 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License
# MIT License

Copyright (c) 2024 Laravel Lang
Copyright (c) 2024 Laravel-Lang Team

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.
> 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.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
[![Github Workflow Status][badge_build]][link_build]
[![License][badge_license]](https://laravel-lang.com/license.html)

## ToDo

Localization by:

- [x] route parameter (+ redirect)
- [x] header
- [ ] cookies
- [ ] session data ?

## Documentation

See the [documentation](https://laravel-lang.com/packages-routes.html) for detailed installation.
Expand Down
78 changes: 78 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "laravel-lang/routes",
"description": "Easy and fast way to localize routes",
"license": "MIT",
"keywords": [
"laravel",
"languages",
"routes",
"translations",
"translate",
"localization",
"l18n"
],
"authors": [
{
"name": "Andrey Helldar",
"email": "[email protected]",
"homepage": "https://dragon-code.pro"
},
{
"name": "Laravel-Lang Team",
"homepage": "https://github.com/Laravel-Lang"
}
],
"support": {
"issues": "https://github.com/Laravel-Lang/routes/issues",
"source": "https://github.com/Laravel-Lang/routes"
},
"require": {
"php": "^8.2",
"dragon-code/support": "^6.13",
"illuminate/config": "^10.0 || ^11.0",
"illuminate/http": "^10.0 || ^11.0",
"illuminate/support": "^10.0 || ^11.0",
"laravel-lang/config": "^1.1",
"laravel-lang/locales": "^2.8"
},
"require-dev": {
"orchestra/testbench": "^8.23 || ^9.1",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.4",
"symfony/var-dumper": "^6.0 || ^7.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"LaravelLang\\Routes\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dragon-code/codestyler": true,
"ergebnis/composer-normalize": true,
"pestphp/pest-plugin": true,
"php-http/discovery": true,
"symfony/thanks": true
},
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"LaravelLang\\Routes\\ServiceProvider"
]
}
},
"scripts": {
"test": "vendor/bin/pest --parallel"
}
}
24 changes: 24 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF" />

<env name="SESSION_DRIVER" value="array" />
<env name="CACHE_STORE" value="array" />
</php>
</phpunit>
16 changes: 16 additions & 0 deletions src/Concerns/KeyNames.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace LaravelLang\Routes\Concerns;

use LaravelLang\Config\Data\RouteNameData;
use LaravelLang\Config\Facades\Config;

trait KeyNames
{
public function names(): RouteNameData
{
return Config::shared()->routes->names;
}
}
15 changes: 15 additions & 0 deletions src/Middlewares/CookiesLocale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace LaravelLang\Routes\Middlewares;

use Illuminate\Http\Request;

class CookiesLocale extends Middleware
{
protected function detect(Request $request): bool|float|int|string|null
{
return $request->cookie($this->names()->cookie);
}
}
15 changes: 15 additions & 0 deletions src/Middlewares/HeaderLocale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace LaravelLang\Routes\Middlewares;

use Illuminate\Http\Request;

class HeaderLocale extends Middleware
{
protected function detect(Request $request): bool|float|int|string|null
{
return $request->header($this->names()->header);
}
}
Loading

0 comments on commit 40de5a6

Please sign in to comment.