Čamo
Čamo

Reputation: 4172

Astrotomic/laravel-translatable add new language dynamically

can somebody tell me please how to achieve this in astrotomic/laravel-translatable package? I need to add new language to the app dynamically. There is config/translatable.php which contains

'locales' => ['en', 'cs', 'cz', 'sk', 'pl',  'de', 'hu',  'uk',  'us', 'gb', ],

This does not allow to add new language which is not defined in this array. I have a controller which want to add new languages and tries to do it this way. This lines runs before new lang is added to the app.

config([
    'translatable.locales'         => $newLocales,
    'translatable.locale'          => $data['default_language'],
    'translatable.fallback_locale' => $data['default_language'],
]);

I thought this will change the config and library will add new language. But the library allow only the languages which are in config file array. How can I dynamically add new languages to the application? Thanks.

Upvotes: 0

Views: 132

Answers (0)

Related Questions