vojtasvoboda / oc-twigextensions-plugin

Twig extensions plugin for OctoberCMS
MIT License
18 stars 26 forks source link

Custom plugin and custom lang.php file #56

Closed faselunare closed 5 years ago

faselunare commented 5 years ago

Hi, in my custom plugin's template, I want to use the time_diff function it works perfectly but I want a custom translation from this

return [
    'diff' => [
        'empty' => 'now',
        'ago' => [
            'year' => '1 year ago|:count years ago',
            'month' => '1 month ago|:count months ago',
            'day' => '1 day ago|:count days ago',
            'hour' => '1 hour ago|:count hours ago',
            'minute' => '1 minute ago|:count minutes ago',
            'second' => '1 second ago|:count seconds ago',
        ],
        'in' => [
            'second' => 'in 1 second|in :count seconds',
            'hour' => 'in 1 hour|in :count hours',
            'minute' => 'in 1 minute|in :count minutes',
            'day' => 'in 1 day|in :count days',
            'month' => 'in 1 month|in :count months',
            'year' => 'in 1 year|in :count years',
        ],
    ],
];

to this

 return [
     'diff' => [
         'empty' => 'now',
         'ago' => [
             'year' => '1y|:count y',
             'month' => '1m|:count m',
             'day' => '1d|:count d',
             'hour' => '1h|:count h',
             'minute' => '1m|:count m',
             'second' => '1s|:count s',
         ],
         'in' => [
             'second' => 'in 1 second|in :count seconds',
             'hour' => 'in 1 hour|in :count hours',
             'minute' => 'in 1 minute|in :count minutes',
             'day' => 'in 1 day|in :count days',
             'month' => 'in 1 month|in :count months',
             'year' => 'in 1 year|in :count years',
         ],
     ],
 ];

but only for my plugin (leaving untouched the original lang.php) Is it possible? in which way?

Thanks

vojtasvoboda commented 5 years ago

Yes, it is possible, just create /lang folder in your project folder. For example check https://github.com/vojtasvoboda/oc-brands-plugin-override-example