Carbon change language to Czech - laravel-5

I am trying to show date in article with $article->created_at->diffForHumans() and for now I am getting English language for example: 2 hours ago.
I would like to get the date in Czech language.
What I have tried:
By this articles: Laravel 5 Carbon global Locale, How to set language for Carbon?
In AppServicePrivider.php I set it up locale for Carbon.
`public function boot()
{
Carbon::setLocale('cz');
}`
But it did not work. I also tried different language as German, Spanish and French all works except Czech.
I am using Laravel 5.6.

Related

Laravel - DataTable Localization

Morning,
I'm building a multilanguage site with Laravel.
Changing of display language is OK, when user select language (fr or en).
But only DataTable options are not translated (search, previous, ...).
I can translate it into Datable {language:..} but this method is static.
Thks for your help !
I did the same thing for the datatable,
You can use laravel lang function and blade syntax for mixing php into script ,
to do that,You can use laravel lang function for language property for dynamic localization
Here is sample for:
$('#example').DataTable( {
"language": {
"lengthMenu":"{!!__('dataTable.menu')!!}",
"zeroRecords": "{!!__('dataTable.zeroRecord')!!}",
....
}
} );
And in resources/lang folder in your laravel project, create correspond php file array for your desired languages
For more information about laravel localization check this

Changing locale for thymeleaf utility objects

I want to use #dates or #calendars to get a list of the elapsed months of the current year. This can be achieved using ${#dates.monthName(date)} and a bit of logic, but the name of the months comes in english, and I need it in spanish.
Is there a way to tell thymeleaf to use one locale or another? I've read it uses the standard Date and Calendar from Java, so maybe some sort of application settings for this classes in spring would work?
You've to use the method monthName(Object target, Locale locale) of Thymeleaf DateUtils.
I think something like this should work:
${T(org.thymeleaf.util.DateUtils).monthName(#dates.createNow(), #locale.getDefault())}

How to switch view by locale in Laravel 6?

I'd like to use different views for different locale in Laravel 6 instead of translate phrase by phrase.
Is there some mechanism or package that allows to do it?
Otherwhise how could I write my views and controllers such that it would be done cleanly and relaiably?
Thanks in advance
Order your views into language maps (e.g. the English view for "test" as en\test.blade.php, the French view fr\test.blade.php)
Then use a locale variable from your route to determine the view that is returned.
For example: Route::get('{locale}/test', 'SomeController#test');
public function test($locale)
{
return view($locale.'test');
}

CodeIgniter translate PHP date

I have a datetime stored in mysql as timestamp.
I then format the datetime using
$newdate = date('d M Y', strtotime($this->query->datetime));
My question is how do I translate the date using codeigniter builtin lang helper?
in the application language folder add a subfolder for the language you want to translate to. In that folder make a file called date_lang.php and handle all you date translations.
$lang['datefrom'] = "dateTo";
Another option for translation of dates is to use locale.
PHP will handle the date translations for you. Set the locale globally for the user.
setlocale(LC_ALL, 'en_UK.utf8');
In my current project, we use the locale to handle money and dates. We use CI language files to handle string translations

Codeigniter calendar language problem

I'm trying to get the calendar in CodeIgniter to print month names in Swedish.
In config.php I have this line:
$config ['language'] = 'Swedish';
In autoload.php I have this line:
$autoload ['language'] = array ('calendar');
In my controller:
$this->lang->load('calendar', 'swedish');
So here I am trying to print the date:
<? php echo date ('d M Y', $row['pubDate']);?>
The result is as: 23 May 2011
Month names are printed in English, which is wrong, I want it in Swedish. I have calendar_lang.php in Swedish.
Any advice on how I solve this?
Codeigniter lang files are decided to "translate" only codeigniter functions, methods etc.
They do not affect default php function, like that one you are using (date).
You should look at this page and follow the links on that page.

Resources