Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

Locale

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

The Locale Component.

Example

<?php

use miBadger\Locale;

/**
 * Initialize the locales.
 * This uses the directory 'locale' to look for the translation files, and the 'messages' text domain.
 * Make sure the correct folders and MO files are created! See below for more information.
 */
Locale::init(__DIR__ . '/locale', 'messages');

/**
 * Add the different available locales.
 */
Locale::add('nl', 'nl_NL.UTF-8');
Locale::add('de', 'de_DE.UTF-8');

/**
 * Choose what locale you want to use.
 */
Locale::set('nl');

/**
 * Now you can use gettext, which should return the translated strings (if present in the MO files).
 * It is also possible to call another set() function to chance locale.
 */

Translation files

Given the example above, the following files should be present:

locale/
	nl_NL/
		LC_MESSAGES/
			messages.mo
	de_DE/
		LC_MESSAGES/
			messages.mo

The locale directory is set in the Locale::init function. The second parameter is the text domain (for our purposes, the name of the MO files).

About

The Locale component

Resources

License

Packages

No packages published

Languages