Open camohub opened 2 months ago
Hi, @camohub. It does not work, because the library does not access directly to the configurations and works with the helper class Locales
. In general, after setting new locales you need to reload it with method load
config([
'translatable.locales' => $newLocales,
'translatable.locale' => $data['default_language'],
'translatable.fallback_locale' => $data['default_language'],
]);
resolve(Locales::class)->load();
You can check how it's works in test suite: https://github.com/Astrotomic/laravel-translatable/blob/0d065da7fb06b4b957afce79fdda159764561345/tests/LocalesTest.php#L21-L36
Thank you very much. It seems it works. Where in the documentation I can find this?
@camohub, about load
method - https://docs.astrotomic.info/laravel-translatable/package/locales-helper#load
Thanks again.
Hi there, can somebody tell me please how to achieve this. I need to add new language to the app dynamically. There is config/translatable.php which contains
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.
I thought this will cange 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.