Giter Club home page Giter Club logo

Comments (4)

rxcod9 avatar rxcod9 commented on May 28, 2024

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

from joy-voyager-api.

ruwad-co avatar ruwad-co commented on May 28, 2024

@rxcod9
i have add changelanguage middleware and add to karnel

`<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class ChangeLanguage
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
app()->setLocale('ar');
if(isset($request -> lang) && $request -> lang == 'en')
app()->setLocale('en');
return $next($request);
}
}`

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

from joy-voyager-api.

rxcod9 avatar rxcod9 commented on May 28, 2024

@gogo207

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

from joy-voyager-api.

ruwad-co avatar ruwad-co commented on May 28, 2024

@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
}

from joy-voyager-api.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.