laravelrus / localized-carbon Goto Github PK
View Code? Open in Web Editor NEWA localizable version of Carbon
A localizable version of Carbon
ErrorException with message 'Declaration of Laravelrus\LocalizedCarbon\LocalizedCarbon::diffForHumans() should be compatible with Carbon\Carbon::diffForHumans(Carbon\Carbon $other = NULL, $absolute = false, $short = false, $parts = 1)'
recently updated the package and this error appeared
laravel 5.3
localized-carbon version "dev-master"
steps to reproduce error:
Laravel Version: 5.6
in my page i show posts and i use diffForHumans to display how mush time pass when post created and i translate it usin Localized Carbon in arabic language . it's working but in days he display number of days two times . for exemple instead of showing 5 days ago. he display 5 5 days ago
Could you modify composer.json so this package can be used from day 1 that Laravel 5 is available?
не планируется ли делать переводы для метода formatLocalized для %A параметра? это день недели (понедельник, вторник, etc)
Hello,
great package...
i am using it to have arabic dates.
my issue is in localizedFormat() where i need the months names in arabic.
i did vendor:publish and realized there is no months.php file in the lang\ar folder.
i created it and still couldn't retrieve the values.
after digging, i had to change one line of code in the localizedFormat() function
$replace = \Lang::get("months." . $langKey); //had to remove localized-carbon::
now my lang files are being loaded.
did i miss something ? is there any other way around without changing the source code ?
Instead of a model to extend. This would bump the package to 5.4+ but then again 5.3 is now EOL and most packages are now 5.4+ so
I have gone threw the Readme, but still didn't get the idea, on how to choose the language to which I want the date to be translated.
How about short version of days and months?
D A textual representation of a day, three letters Mon through Sun
M A short textual representation of a month, three letters Jan through Dec
And even shorter days:
Пн, Вт, Ср, Чт, Пт, Сб, Вс
a similar problem for version 5.4 was here #96
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework v5.3.31
- Conclusion: don't install laravel/framework v5.3.31
- Conclusion: don't install laravel/framework v5.3.30
- Conclusion: don't install laravel/framework v5.3.29
- Conclusion: don't install laravel/framework v5.3.28
- Conclusion: don't install laravel/framework v5.3.27
- Conclusion: don't install laravel/framework v5.3.26
- Conclusion: don't install laravel/framework v5.3.25
- Conclusion: don't install laravel/framework v5.3.24
- Conclusion: don't install laravel/framework v5.3.23
- Conclusion: don't install laravel/framework v5.3.22
- Conclusion: don't install laravel/framework v5.3.21
- Conclusion: don't install laravel/framework v5.3.20
- Conclusion: don't install laravel/framework v5.3.19
- Conclusion: don't install laravel/framework v5.3.18
- Conclusion: don't install laravel/framework v5.3.17
- Conclusion: don't install laravel/framework v5.3.16
- Conclusion: don't install laravel/framework v5.3.15
- Conclusion: don't install laravel/framework v5.3.14
- Conclusion: don't install laravel/framework v5.3.13
- Conclusion: don't install laravel/framework v5.3.12
- Conclusion: don't install laravel/framework v5.3.11
- Conclusion: don't install laravel/framework v5.3.10
- Conclusion: don't install laravel/framework v5.3.9
- Conclusion: don't install laravel/framework v5.3.8
- Conclusion: don't install laravel/framework v5.3.7
- Conclusion: don't install laravel/framework v5.3.6
- Conclusion: don't install laravel/framework v5.3.5
- Conclusion: don't install laravel/framework v5.3.4
- Conclusion: don't install laravel/framework v5.3.3
- Conclusion: don't install laravel/framework v5.3.2
- Conclusion: don't install laravel/framework v5.3.1
- laravelrus/localized-carbon dev-master requires illuminate/support >=5.5.0 -> satisfiable by illuminate/support[5.7.17, 5.7.18, 5.7.19, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.2, v5.8.3, v5.8.4, v5.8.8, v5.8.9].
- laravelrus/localized-carbon dev-master requires illuminate/support >=5.5.0 -> satisfiable by illuminate/support[5.7.17, 5.7.18, 5.7.19, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.2, v5.8.3, v5.8.4, v5.8.8, v5.8.9].
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.0
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.16
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.17
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.2
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.28
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.33
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.34
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.35
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.36
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.37
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.39
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.40
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.41
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.43
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.5.44
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.0
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.1
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.10
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.11
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.12
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.13
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.14
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.15
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.16
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.17
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.19
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.2
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.20
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.21
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.22
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.23
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.24
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.25
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.26
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.27
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.28
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.29
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.3
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.30
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.31
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.32
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.33
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.34
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.35
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.36
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.37
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.38
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.39
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.4
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.5
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.6
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.7
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.8
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.6.9
- don't install laravel/framework v5.3.0|don't install illuminate/support 5.7.17
- don't install laravel/framework v5.3.0|don't install illuminate/support 5.7.18
- don't install laravel/framework v5.3.0|don't install illuminate/support 5.7.19
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.0
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.1
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.10
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.11
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.15
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.2
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.20
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.21
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.22
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.23
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.26
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.27
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.28
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.3
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.4
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.5
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.6
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.7
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.8
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.7.9
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.0
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.11
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.12
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.14
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.15
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.2
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.3
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.4
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.8
- don't install laravel/framework v5.3.0|don't install illuminate/support v5.8.9
- Installation request for laravel/framework 5.3.* -> satisfiable by laravel/framework[v5.3.0, v5.3.1, v5.3.10, v5.3.11, v5.3.12, v5.3.13, v5.3.14, v5.3.15, v5.3.16, v5.3.17, v5.3.18, v5.3.19, v5.3.2, v5.3.20, v5.3.21, v5.3.22, v5.3.23, v5.3.24, v5.3.25, v5.3.26, v5.3.27, v5.3.28, v5.3.29, v5.3.3, v5.3.30, v5.3.31, v5.3.4, v5.3.5, v5.3.6, v5.3.7, v5.3.8, v5.3.9].
- Installation request for laravelrus/localized-carbon dev-master -> satisfiable by laravelrus/localized-carbon[dev-master].
Declaration of Laravelrus\LocalizedCarbon\LocalizedCarbon::diffForHumans()
should be compatible with
Carbon\Carbon::diffForHumans(Carbon\Carbon $other = NULL, $absolute = false, $short = false)
When I've tried to use this package I ran into this error
Call to undefined method [package] @ LocalizedCarbonServiceProvider.php line 21
I use:
I have error:
Declaration of Laravelrus\LocalizedCarbon\LocalizedCarbon::diffForHumans(?Carbon\Carbon $other = NULL, $formatter = NULL) should be compatible with Carbon\Carbon::diffForHumans($other = NULL, $absolute = false, $short = false, $parts = 1) (View: resources/views/events/index.blade.php)
Thanks...
Hi, now there is not much info about that feature.
According to the docs, I have to use %f
, but, unfortunately, I have to use %%f
to make it work.
This is not straightforward, especially for a novice.
So, I suggest correcting the docs with %%f
and probably adding some example, smth like this:
// Output in RU: 16 декабря 2014, 18:11
LocalizedCarbon::instance($post->created_at)->formatLocalized('%d %%f %Y, %H:%M');
[user@hosting]$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework v5.4.36
- Conclusion: don't install laravel/framework v5.4.36
- Conclusion: don't install laravel/framework v5.4.35
- Conclusion: don't install laravel/framework v5.4.34
- Conclusion: don't install laravel/framework v5.4.33
- Conclusion: don't install laravel/framework v5.4.32
- Conclusion: don't install laravel/framework v5.4.31
- Conclusion: don't install laravel/framework v5.4.30
- Conclusion: don't install laravel/framework v5.4.29
- Conclusion: don't install laravel/framework v5.4.28
- Conclusion: don't install laravel/framework v5.4.27
- Conclusion: don't install laravel/framework v5.4.26
- Conclusion: don't install laravel/framework v5.4.25
- Conclusion: don't install laravel/framework v5.4.24
- Conclusion: don't install laravel/framework v5.4.23
- Conclusion: don't install laravel/framework v5.4.22
- Conclusion: don't install laravel/framework v5.4.21
- Conclusion: don't install laravel/framework v5.4.20
- Conclusion: don't install laravel/framework v5.4.19
- Conclusion: don't install laravel/framework v5.4.18
- Conclusion: don't install laravel/framework v5.4.17
- Conclusion: don't install laravel/framework v5.4.16
- Conclusion: don't install laravel/framework v5.4.15
- Conclusion: don't install laravel/framework v5.4.14
- Conclusion: don't install laravel/framework v5.4.13
- Conclusion: don't install laravel/framework v5.4.12
- Conclusion: don't install laravel/framework v5.4.11
- Conclusion: don't install laravel/framework v5.4.10
- Conclusion: don't install laravel/framework v5.4.9
- Conclusion: don't install laravel/framework v5.4.8
- Conclusion: don't install laravel/framework v5.4.7
- Conclusion: don't install laravel/framework v5.4.6
- Conclusion: don't install laravel/framework v5.4.5
- Conclusion: don't install laravel/framework v5.4.4
- Conclusion: don't install laravel/framework v5.4.3
- Conclusion: don't install laravel/framework v5.4.2
- Conclusion: don't install laravel/framework v5.4.1
- laravelrus/localized-carbon dev-master requires illuminate/support >=5.5.0 -> satisfiable by illuminate/support[v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.2, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
- laravelrus/localized-carbon dev-master requires illuminate/support >=5.5.0 -> satisfiable by illuminate/support[v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.2, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
- don't install illuminate/support v5.5.0|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.16|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.17|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.2|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.28|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.33|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.34|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.35|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.36|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.37|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.39|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.5.40|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.0|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.1|don't install laravel/framework v5.4.0
- illuminate/support v5.6.10 conflicts with laravel/framework[v5.4.0].
- illuminate/support v5.6.11 conflicts with laravel/framework[v5.4.0].
- illuminate/support v5.6.12 conflicts with laravel/framework[v5.4.0].
- illuminate/support v5.6.13 conflicts with laravel/framework[v5.4.0].
- illuminate/support v5.6.14 conflicts with laravel/framework[v5.4.0].
- illuminate/support v5.6.15 conflicts with laravel/framework[v5.4.0].
- don't install illuminate/support v5.6.2|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.3|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.4|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.5|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.6|don't install laravel/framework v5.4.0
- don't install illuminate/support v5.6.7|don't install laravel/framework v5.4.0
- illuminate/support v5.6.8 conflicts with laravel/framework[v5.4.0].
- illuminate/support v5.6.9 conflicts with laravel/framework[v5.4.0].
- Installation request for laravel/framework 5.4.* -> satisfiable by laravel/framework[v5.4.0, v5.4.1, v5.4.10, v5.4.11, v5.4.12, v5.4.13, v5.4.14, v5.4.15, v5.4.16, v5.4.17, v5.4.18, v5.4.19, v5.4.2, v5.4.20, v5.4.21, v5.4.22, v5.4.23, v5.4.24, v5.4.25, v5.4.26, v5.4.27, v5.4.28, v5.4.29, v5.4.3, v5.4.30, v5.4.31, v5.4.32, v5.4.33, v5.4.34, v5.4.35, v5.4.36, v5.4.4, v5.4.5, v5.4.6, v5.4.7, v5.4.8, v5.4.9].
- Installation request for laravelrus/localized-carbon dev-master -> satisfiable by laravelrus/localized-carbon[dev-master].
Все поставил как в интсрукции. Но {{ $comment->created_at->diffForHumans() }}
все равно выводит дуту на английском. В /config/app.php
параметр 'locale' => 'ru'
. Что я делаю не так?
если к модели добавить трейт LocalizedEloquentTrait, то для нее не будут работать faker, при попытке заполнить тестовые значения в базе. ошибка следующая:
[ErrorException]
preg_match() expects parameter 2 to be string, object given
что то похожее описано здесь:
https://laracasts.com/discuss/channels/testing/error-testdummy , но там это оказалось связанно с отсутствием __toString()
метода, а тут он есть...
пока загадка, почему так
Изменил"locale"=>"ru"
в config/app.php;
В классе LocalizedCarbon
изменил константу const DEFAULT_LANGUAGE = 'ru';
Но локализация всё равно английская.
Declaration of Laravelrus\LocalizedCarbon\LocalizedCarbon::diffForHumans(?Carbon\Carbon $other = NULL, $formatter = NULL, $short = false) should be compatible with Carbon\Carbon::diffForHumans(?Carbon\Carbon $other = NULL, $absolute = false, $short = false, $parts = 1)
if use carbon v1.24.1 - all is good
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.