Multi-language support

I want to develop a REST api using slim and i want my response to be localized based on request’s locale . How can i do this in slim ?

I don’t know your exact requirements and your description is too vague. It’s hard to guess what’s the right solution for you. But you could implement a custom middleware. Here is a small example as inspiration:

// Browser language detection middleware
$app->add(function (Request $request, Response $response, $next) {
    $language = $request->getHeader('accept-language')[0];
    $language = explode(',', $language)[0];
    $language = explode('-', $language)[0];

    $request = $request->withAttribute('language', $language);

    return $next($request, $response);
});