Skip to content

llvdl/Slim-Translations-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slim Translations example

An example application based on Slim Framework 3 that uses Twig for rendering and illuminate/translation for translations.

The application creates a Translator instance and registers the trans and transChoice functions so they can be used in Twig templates.

The setup of the view and the translator can be found in app/config/dependencies.php.

The Twig templates are stored in app/templates. Translation files are stored in app/translations. These paths are configured in app/bootstrap.php.

The current language is set using middleware (see App\MiddleWare\LocaleMiddleware):

  • It looks for the current locale in the URL path, e.g. "/en/home" yields "en"
  • Otherwise it looks for the locale set in the current session
  • Otherwise it uses the default locale.

The icons were made by cactus cowboy.

Installation

After cloning this repository, install the dependencies using composer:

composer install

Note: You may need to install the php mbstring extension. When running composer install, you will be notified if this is the case.

Running

Start the PHP built-in web server from the terminal:

php -S localhost:8000 -t web

If the server has succesfully started, open the following url in your browser: http://localhost:8000

Running using Apache, Nginx or other web servers

Please see the Slim documentation on adding the correct configuration file for running this application using a web server other than the PHP built-in web server: https://www.slimframework.com/docs/v3/start/web-servers.html

About

Example Slim 3 application with translations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published