rxcod9 / joy-voyager-api

Joy VoyagerApi module adds REST Api end points to Voyager with Passport and Swagger support.
https://joy-voyager.kodmonk.com
MIT License
19 stars 4 forks source link

language params #14

Closed ruwad-co closed 2 years ago

ruwad-co commented 2 years ago

can you add language params to api like https://joy-voyager-api.herokuapp.com/api/posts/1?lang=en

rxcod9 commented 2 years ago

You can set app locale through middleware Where you can receive language through query, header, body, or sub domain etc

ruwad-co commented 2 years ago

@rxcod9 i have add changelanguage middleware and add to karnel

`<?php

namespace App\Http\Middleware;

use Closure; use Illuminate\Http\Request;

class ChangeLanguage { /**

karnel 'changelang' => \App\Http\Middleware\ChangeLanguage::class, where can add changelang Middleware now sory i am new on laravel

rxcod9 commented 2 years ago

@gogo207

This should solve your problem https://stackoverflow.com/questions/38039159/how-to-assign-middleware-to-routes-in-laravel-better-way/50926301

ruwad-co commented 2 years ago

@rxcod9 not working The response is always returned in the default language and the response does not appear in the other language http://adensoft-voyager.com/api/articals/1?lang=en

{ "data": { "id": 1, "title": "Title ar", "long_text": "Long Text ar", "created_at": "2021-11-05T10:27:00.000000Z", "updated_at": "2021-11-05T10:27:00.000000Z", "translations": [ { "id": 45, "table_name": "articals", "column_name": "long_text", "foreign_key": 1, "locale": "en", "value": "Long Text en", "created_at": "2021-11-05T10:27:00.000000Z", "updated_at": "2021-11-05T10:27:00.000000Z" }, { "id": 44, "table_name": "articals", "column_name": "title", "foreign_key": 1, "locale": "en", "value": "Title en", "created_at": "2021-11-05T10:27:00.000000Z", "updated_at": "2021-11-05T10:27:00.000000Z" } ] }, "isModelTranslatable": true, "isSoftDeleted": false }