Skip to content
This package helps you to resolve the language in a URL.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.styleci.yml
.travis.yml
LICENSE
README.md
composer.json
composer.lock
phpunit.xml

README.md

URL Language extractor

Build status StyleCI Status Code coverage Total Downloads Latest Stable Version License

This package helps you to resolve the language in a URL.

Requirements

  • php >= 7.2

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.

You can’t perform that action at this time.