diff --git a/app/Http/Controllers/LanguageController.php b/app/Http/Controllers/LanguageController.php index b6a1ab8e..44688452 100644 --- a/app/Http/Controllers/LanguageController.php +++ b/app/Http/Controllers/LanguageController.php @@ -33,7 +33,13 @@ public function switchLang($posixLocale) */ protected function setSessionLanguage($posixLocale) { - $localeSubtags = locale_parse($posixLocale); + //$localeSubtags = locale_parse($posixLocale); + if (function_exists('locale_parse')) { + $localeSubtags = locale_parse($posixLocale); + } else { + $localeSubtags = array('language' => substr($posixLocale, 0, 2)); + } + $language = array_get($localeSubtags, 'language'); session()->set('language', $language); diff --git a/app/helpers.php b/app/helpers.php index 962a0bbc..654c07b1 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,6 +1,7 @@ setLocale($posixLocale); setlocale(LC_TIME, $posixLocale); - Carbon::setLocale(locale_get_primary_language($posixLocale)); + //Carbon::setLocale(locale_get_primary_language($posixLocale)); + if (function_exists('locale_get_primary_language')) { + Carbon::setLocale(locale_get_primary_language($posixLocale)); + } else { + Carbon::setLocale(Language::name($posixLocale)); + } + } } diff --git a/bootstrap/app.php b/bootstrap/app.php index a5d60f6c..ebc9d9ef 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -41,6 +41,8 @@ App\Exceptions\Handler::class ); +$app->register(Propaganistas\LaravelIntl\IntlServiceProvider::class); + # $app->useStoragePath(env('STORAGE_PATH', $app->storagePath())); /* diff --git a/composer.json b/composer.json index 19544720..d1b8f348 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,8 @@ "torann/geoip": "1.0.*", "geoip2/geoip2": "~2.1", "seanstewart/plan-config": "dev-master", - "nesbot/carbon": "^1.22" + "nesbot/carbon": "^1.22", + "propaganistas/laravel-intl": "^2.0" }, "require-dev": { "barryvdh/laravel-debugbar": "^2.0", diff --git a/composer.lock b/composer.lock index 5ef89fb9..0779629a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "1b7a01188afbd8f1324ace2a48e31846", + "content-hash": "d9b833cebf2aca9a69be0841b7a4a0bd", "packages": [ { "name": "alariva/tidiochat", @@ -277,6 +277,50 @@ ], "time": "2016-09-16T12:50:15+00:00" }, + { + "name": "commerceguys/intl", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/commerceguys/intl.git", + "reference": "22156e447530d6ebd387bfee51ef1ae2c70a5ff0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/commerceguys/intl/zipball/22156e447530d6ebd387bfee51ef1ae2c70a5ff0", + "reference": "22156e447530d6ebd387bfee51ef1ae2c70a5ff0", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "mikey179/vfsstream": "1.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "CommerceGuys\\Intl\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bojan Zivanovic" + } + ], + "description": "Internationalization library powered by CLDR data.", + "time": "2018-06-21T14:03:04+00:00" + }, { "name": "creativeorange/gravatar", "version": "1.0.9", @@ -1635,6 +1679,71 @@ ], "time": "2016-12-10T11:39:28+00:00" }, + { + "name": "jenssegers/date", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/jenssegers/date.git", + "reference": "3f5f94f28bd5108fab011869434209101d4189ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jenssegers/date/zipball/3f5f94f28bd5108fab011869434209101d4189ae", + "reference": "3f5f94f28bd5108fab011869434209101d4189ae", + "shasum": "" + }, + "require": { + "nesbot/carbon": "^1.0", + "php": ">=5.6", + "symfony/translation": "^2.7|^3.0|^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0|^6.0|^7.0", + "satooshi/php-coveralls": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + }, + "laravel": { + "providers": [ + "Jenssegers\\Date\\DateServiceProvider" + ], + "aliases": { + "Date": "Jenssegers\\Date\\Date" + } + } + }, + "autoload": { + "psr-4": { + "Jenssegers\\Date\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jens Segers", + "homepage": "https://jenssegers.com" + } + ], + "description": "A date library to help you work with dates in different languages", + "homepage": "https://github.com/jenssegers/date", + "keywords": [ + "carbon", + "date", + "datetime", + "i18n", + "laravel", + "time", + "translation" + ], + "time": "2018-05-16T11:53:55+00:00" + }, { "name": "jenssegers/rollbar", "version": "v1.5.0", @@ -2932,12 +3041,12 @@ "version": "V1.1.0", "source": { "type": "git", - "url": "https://github.com/jjriv/emogrifier.git", + "url": "https://github.com/MyIntervals/emogrifier.git", "reference": "dd9442740e044a11968bf6a5d94460a5426a2419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jjriv/emogrifier/zipball/dd9442740e044a11968bf6a5d94460a5426a2419", + "url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/dd9442740e044a11968bf6a5d94460a5426a2419", "reference": "dd9442740e044a11968bf6a5d94460a5426a2419", "shasum": "" }, @@ -3025,6 +3134,69 @@ ], "time": "2014-08-09T23:24:27+00:00" }, + { + "name": "propaganistas/laravel-intl", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/Propaganistas/Laravel-Intl.git", + "reference": "645a34430ae92d287e97a06815d613be1f3002b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Propaganistas/Laravel-Intl/zipball/645a34430ae92d287e97a06815d613be1f3002b5", + "reference": "645a34430ae92d287e97a06815d613be1f3002b5", + "shasum": "" + }, + "require": { + "commerceguys/intl": "^1.0.1", + "illuminate/support": ">=5.1,<5.7", + "jenssegers/date": "^3.2.3", + "php": ">=7.0", + "punic/punic": "^3.1", + "umpirsky/country-list": "^2.0", + "umpirsky/locale-list": "^1.0" + }, + "require-dev": { + "orchestra/testbench": ">=3.1", + "phpunit/phpunit": "^5.0|^6.0|^7.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Propaganistas\\LaravelIntl\\IntlServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Propaganistas\\LaravelIntl\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Propaganistas", + "email": "Propaganistas@users.noreply.github.com" + } + ], + "description": "Easy to use internationalization functions for Laravel", + "keywords": [ + "i18n", + "internationalization", + "intl", + "l10n", + "laravel" + ], + "time": "2018-07-03T07:55:17+00:00" + }, { "name": "propaganistas/laravel-phone", "version": "2.8.1", @@ -3251,6 +3423,75 @@ ], "time": "2016-03-09T05:03:14+00:00" }, + { + "name": "punic/punic", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/punic/punic.git", + "reference": "bd49ff54ea6ee8a902a567905664ecc7840037d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/punic/punic/zipball/bd49ff54ea6ee8a902a567905664ecc7840037d6", + "reference": "bd49ff54ea6ee8a902a567905664ecc7840037d6", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "replace": { + "punic/calendar": "*", + "punic/common": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "2.2.*", + "phpunit/phpunit": "^4" + }, + "bin": [ + "bin/punic-data" + ], + "type": "library", + "autoload": { + "psr-4": { + "Punic\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michele Locati", + "email": "mlocati@gmail.com", + "role": "Developer" + }, + { + "name": "Remo Laubacher", + "email": "remo.laubacher@gmail.com", + "role": "Collaborator, motivator and perfectionist supporter" + } + ], + "description": "PHP-Unicode CLDR", + "homepage": "https://github.com/punic/punic", + "keywords": [ + "calendar", + "cldr", + "date", + "date-time", + "i18n", + "internationalization", + "l10n", + "localization", + "php", + "time", + "translate", + "translations", + "unicode" + ], + "time": "2018-02-09T15:54:34+00:00" + }, { "name": "ramsey/uuid", "version": "3.5.2", @@ -4511,7 +4752,7 @@ "reservation", "timegrid" ], - "time": "2016-10-19 15:55:40" + "time": "2016-10-19T15:55:40+00:00" }, { "name": "timegridio/icalreader", @@ -4579,7 +4820,7 @@ "timegrid", "timegridio" ], - "time": "2016-07-10 01:10:52" + "time": "2016-07-10T01:10:52+00:00" }, { "name": "torann/geoip", @@ -4730,6 +4971,83 @@ ], "time": "2015-04-27T04:02:14+00:00" }, + { + "name": "umpirsky/country-list", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/umpirsky/country-list.git", + "reference": "ddabf3a8ef2956fc0fbd22da9bec642ab6cfdede" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/umpirsky/country-list/zipball/ddabf3a8ef2956fc0fbd22da9bec642ab6cfdede", + "reference": "ddabf3a8ef2956fc0fbd22da9bec642ab6cfdede", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "slowprog/composer-copy-file": "^0.2", + "symfony/locale": "^2.7|^3.0", + "umpirsky/list-generator": "^1.2" + }, + "type": "library", + "extra": { + "copy-file": { + "vendor/umpirsky/list-generator/Dockerfile": "./", + "vendor/umpirsky/list-generator/docker-compose.yml": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Saša Stamenković", + "email": "umpirsky@gmail.com" + } + ], + "description": "List of all countries with names and ISO 3166-1 codes in all languages and data formats.", + "time": "2018-02-27T18:55:19+00:00" + }, + { + "name": "umpirsky/locale-list", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/umpirsky/locale-list.git", + "reference": "8141f749e16e568a5a9f7e813c50f72efa794c2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/umpirsky/locale-list/zipball/8141f749e16e568a5a9f7e813c50f72efa794c2e", + "reference": "8141f749e16e568a5a9f7e813c50f72efa794c2e", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "symfony/locale": "^2.7|^3.0", + "umpirsky/list-generator": "^1.1" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Saša Stamenković", + "email": "umpirsky@gmail.com" + } + ], + "description": "List of all locales with names and codes in all languages and all data formats.", + "time": "2018-06-01T17:50:07+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v2.4.0", diff --git a/config/app.php b/config/app.php index 4fd60a00..fb68beca 100644 --- a/config/app.php +++ b/config/app.php @@ -184,6 +184,8 @@ Timegridio\Concierge\TimegridioConciergeServiceProvider::class, Timegridio\ICalReader\ICalReaderServiceProvider::class, Seanstewart\PlanConfig\PlanConfigServiceProvider::class, + + Propaganistas\LaravelIntl\IntlServiceProvider::class, ], /*