Fuel Documentation

Language Class

The language class allows you to set language variables using language files in your application.

load($file, $group = null)

The load method allows you to load a language file.

Static Yes
Parameters
Param Default Description
$file required The path of the desired file. You can prefix this with a namespace to load a config file from a loaded package or module.
$group
null
Sets a language group to be used.
Returns void
Example
// Example of a language file:
return array(
	'hello' => 'Hello :name',
	'something'=> 'something :name!',
	'test'=> array('hello' => 'Hello', 'something' => 'Plop') // Group
);

// Loads example.php.
// Note: If no language is set in the config, it will fallback to English.
Lang::load('example');

// Will load the given file into the 'test' group.
Lang:load('example', 'test');

// Outputs Plop
$this->output = Lang::line('test.test.something');

// Will load the given file from the module 'foo' into the 'bar' group.
Lang:load('foo\\example', 'bar');

line($line, $params = array())

The line method allows you to get a specific line from the language file.

Static Yes
Parameters
Param Default Description
$line required The desired line's identifier.
$parameters
array()
Sets an array of parameter that might be passed to the line.
Returns string
Example
// Outputs Hello world
$this->output = Lang::line('hello', array('name' => 'world');

// Outputs Plop
$this->output = Lang::line('test.something');

set($line, $value, $group = null)

The set method allows you to set a specific line to the language file.

Static Yes
Parameters
Param Default Description
$line required The desired line's identifier.
$value
array()
Sets the value of the line.
$group
null
Sets a language group to be used.
Returns boolean
Example
// Returns true
Lang::set('hello', 'Ahoy!');

// Using groups
Lang:set('hello', 'Ahoy!', 'test');

// Will also work as above
Lang::load('test', 'test);
Lang::set('hello', 'Ahoy!');