Download the PHP package oorrwullie/yii2-babelfishfood without Composer
On this page you can find all versions of the php package oorrwullie/yii2-babelfishfood. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oorrwullie/yii2-babelfishfood
More information about oorrwullie/yii2-babelfishfood
Files in oorrwullie/yii2-babelfishfood
Package yii2-babelfishfood
Short Description Language switching companion of the Yii2 Babelfish symbiote
License MIT
Informations about the package yii2-babelfishfood
Babel Fish Food
Language switching companion of the Yii2 Babelfish symbiote. It can also be used as a complete stand alone solution to get i18n support up and running quickly for any site built using the standard Yii2 advanced template.
Key Features
- Pre-populated database of 115 languages and dialects to get started quickly. (You can add more using the CRUD or with migrations.) Simply change the active property of the language to add or drop support for the language.
- Configured to use GetText po files out of the box. (Can be switched to add support for database based translations.)
- Detects preferred language based on browser preferences.
- Language switching widget displays languages in native format with native alphabet.
- Widget saves language as a cookie for guests and in the User table for logged in users.
- Complete CRUD implementation for administration of languages.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Configuration
Once the extension is installed :
Create the languages table and add language column to your database:
You select supported languages using the active column for that language in the database. We recommend writing a migration to update your active languages, and turn off any of the default that you are not using.
Configure the component in common/config/main.php:
You need to bootstrap the component for each app you would like translations to work like so: In frontend/config/main.php
Do the same in the backend if you would like to have the switcher there too.
Configure translation extraction:
The i18n section needs to be filled in like so: in common/config/main.php
To use the built-in CRUD to administrate languages, add the following to backend/config/main.php:
Implementation
Designating text to be translated
Wrap text to be translated like so:
To compile translations into po files, navigate to your project toot and run:
The above command is a bit long. There is a bash script in oorrwullie/yii2-babelfishfood named i18n. You can copy that to your project root and update translations by running:
To use the widget in a view:
You can change the label of the dropdown widget (defaults to "Languages: ") and languages can either be normal or uppercase (defaults to uppercase). For example:
To use the CRUD:
Navigate to your backend url + bff like so: www.example.com/backend/bff