roelofjan-elsinga / url-language-extractor
0.2.1
2022-08-05 14:53 UTC
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.7
- friendsofphp/php-cs-fixer: ^2.15
- phpunit/phpunit: ^9.5
- spatie/phpunit-watcher: ^1.11
This package is auto-updated.
Last update: 2024-11-06 18:41:00 UTC
README
This package helps you to resolve the language in a URL.
Requirements
- php ^7.4 || >=8.0
Installation
You can require the package through Composer.
composer require roelofjan-elsinga/url-language-extractor
Usage
You can extract the language from the URL by using the following code:
$short_code = LanguageExtractor::forUrl('/page/en/content-page') ->setAcceptedShortCodes(['en', 'nl', 'es', 'fr']) ->extract(); print $short_code; // 'en'
Contributing
Do you want to contribute to this project? Great! You can contribute by working on the following things:
- Adding additional ways to detect a language from a URL
- Writing tests to detect edge cases
- Filing issues for new features or bugs
Testing
You can run tests by running vendor/bin/phpunit
in your terminal.