{"id":36386282,"url":"https://github.com/dasilvaluis/slim-3-multilingual","last_synced_at":"2026-01-11T15:02:27.792Z","repository":{"id":62519982,"uuid":"72046648","full_name":"dasilvaluis/slim-3-multilingual","owner":"dasilvaluis","description":"Middleware for multi language support in Slim 3  PHP framework","archived":false,"fork":false,"pushed_at":"2018-09-15T18:44:18.000Z","size":29,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T15:24:37.053Z","etag":null,"topics":["i10n","i18n","language","middleware","multilanguage","multilanguage-support","multilingual","php","php-framework","routing","slim"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dasilvaluis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-26T21:38:18.000Z","updated_at":"2025-10-20T20:56:22.000Z","dependencies_parsed_at":"2022-11-02T13:31:53.273Z","dependency_job_id":null,"html_url":"https://github.com/dasilvaluis/slim-3-multilingual","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dasilvaluis/slim-3-multilingual","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasilvaluis%2Fslim-3-multilingual","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasilvaluis%2Fslim-3-multilingual/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasilvaluis%2Fslim-3-multilingual/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasilvaluis%2Fslim-3-multilingual/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dasilvaluis","download_url":"https://codeload.github.com/dasilvaluis/slim-3-multilingual/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasilvaluis%2Fslim-3-multilingual/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28309607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["i10n","i18n","language","middleware","multilanguage","multilanguage-support","multilingual","php","php-framework","routing","slim"],"created_at":"2026-01-11T15:02:27.002Z","updated_at":"2026-01-11T15:02:27.787Z","avatar_url":"https://github.com/dasilvaluis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slim 3 Multilingual\n\nExtension to the [Slim PHP micro-framework](http://www.slimframework.com/) version 3 to enable language based routing, i.e. i18n and l10n.\n\n## Dependencies\n\n* [Slim/Slim](https://github.com/slimphp/Slim) (v3)\n\n## Installation\n\nBy terminal:\n\n```shell\ncomposer require luism-s/multilingualslim\n```\n\n## Usage\n\nThe `$container` is used as an interface between the Middleware and the Routes. \nThe multilinguage middleware injects the following variables into the `$container`: `default_language`, `available_languages` and `language`. \nThe first two are variables set by the developer, and the last is set by the middleware itself and indicates the requested language. \n\n```php\nuse \\Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse \\Psr\\Http\\Message\\ResponseInterface as Response;\n\nrequire '../vendor/autoload.php';\n\n$default_language = 'pt';\n$available_languages = ['pt', 'en'];\n\n$app = new \\Slim\\App();\n$container = $app-\u003egetContainer();\n\n$app-\u003eadd( new \\MultilingualSlim\\LanguageMiddleware($available_languages, $default_language, $container) );\n\n$app-\u003eget('/', function (Request $request, Response $response) {\n    // This works with '/', '/pt' and '/en',\n    // and prints 'Hello' in each language.\n    if ($this-\u003elanguage === 'pt') {\n        return $response-\u003ewrite(\"Olá Mundo\");\n    } elseif($this-\u003elanguage === 'en') {\n        return $response-\u003ewrite(\"Hello World\");\n    }\n});\n\n$app-\u003erun();\n```\n\nYou can also use a library to render templates such as php-view. For example:\n\n```php\n$container['renderer'] = new \\Slim\\Views\\PhpRenderer(\"../views/\");\n\n$app-\u003eget('/home', function (Request $request, Response $response) {\n    // This works with '/home', '/pt/home' and '/en/home', \n    // and returns the template views/base.php.\n    // It also passes the chosen language as an argument accessible from the chosen template.\n    return $this-\u003erenderer-\u003erender($response, \"base.php\", [\n        \"language\" =\u003e $this-\u003elanguage\n    ]);\n});\n```\n\n## Acknowledgements \n\nThis project is largely influenced by [SimoTod/slim-multilanguage](https://github.com/SimoTod/slim-multilanguage), which follows the same philosophy but is made for the version 2 of Slim.\n\n## TODO\n\nDevelop functions to do things such as testing for default language, get current language, compare language, and maybe more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasilvaluis%2Fslim-3-multilingual","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdasilvaluis%2Fslim-3-multilingual","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasilvaluis%2Fslim-3-multilingual/lists"}