C
C
chelkaz2017-03-13 19:15:44
Laravel
chelkaz, 2017-03-13 19:15:44

Laravel - Is it possible to change the translation of a package at the resources level?

For example , the translation of carbon is clumsy. And the built-in ru localization looks like this:
5 дней до
Although it would be more logical:
5 дней назад
If I change the language through a file in the vendor's package itself,
/vendor/nesbot/carbon/src/Carbon/Lang/ru.php
That is before the first update.
How can I change at the level of working directories?
Tried in:
/resources/lang/ru/date.php
Doesn't help...
Translation from the box:

return array(
    'year' => ':count год|:count года|:count лет',
    'y' => ':count год|:count года|:count лет',
    'month' => ':count месяц|:count месяца|:count месяцев',
    'm' => ':count месяц|:count месяца|:count месяцев',
    'week' => ':count неделю|:count недели|:count недель',
    'w' => ':count неделю|:count недели|:count недель',
    'day' => ':count день|:count дня|:count дней',
    'd' => ':count день|:count дня|:count дней',
    'hour' => ':count час|:count часа|:count часов',
    'h' => ':count час|:count часа|:count часов',
    'minute' => ':count минуту|:count минуты|:count минут',
    'min' => ':count минуту|:count минуты|:count минут',
    'second' => ':count секунду|:count секунды|:count секунд',
    's' => ':count секунду|:count секунды|:count секунд',
    'ago' => ':time назад',
    'from_now' => 'через :time',
    'after' => ':time после',
    'before' => ':time до',
);

I call:
function get_time_carbon($date) {
    $carbonated_date = Carbon::parse($date);
    Carbon::setLocale('ru');
    $diff_date = $carbonated_date->diffForHumans(Carbon::now());
    return $diff_date;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-03-13
@Sanasol

https://github.com/LaravelRUS/localized-carbon

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question