kg-bot / laravel-localization-to-vue

Make Laravel standard localization files available in format required by various JavaSript localization packages
MIT License
239 stars 35 forks source link

Feature suggestion: Output Callback #50

Closed pepinows closed 4 years ago

pepinows commented 4 years ago

Hello, i'm using your package together with https://kazupon.github.io/vue-i18n/ Here is the thing: Laravel translation parameters look like ":parameter" Vuei18n expects "{parameter}"

This is my solution: Route::get('/lang/localization.js', function () { $translate = ExportLocalization::export()->toArray(); array_walk_recursive($translate, function (&$v, $k) { $v = preg_replace('/:(\w+)/', '{$1}', $v); }); return response()->json($translate); }); (applied a regex replace on every translated string)

It would be nice to have a built-in callback setting to customize the output

kg-bot commented 4 years ago

Hi @pepinows

I like this suggestion with callback function where you can do whatever you want with output so I'll go in that direction, but I don't know when will I have time for that.

If you wish you can create PR.

kg-bot commented 4 years ago

@pepinows I have just added callback to new release https://github.com/kg-bot/laravel-localization-to-vue/tree/v1.6.4, you can see example at https://github.com/kg-bot/laravel-localization-to-vue/tree/v1.6.4#settings-and-configuration