public static method

Reads data.

Results are aggregated by querying all requested configurations for the requested locale then repeating this process for all locales down the locale cascade. This allows for sparse data which is complemented by data from other sources or for more generic locales. Aggregation can be controlled by either specifying the configurations or a scope to use.


Catalog::read(true, 'message', 'zh');
Catalog::read('default', 'message', 'zh');
Catalog::read('default', 'validation.postalCode', 'en_US');


  • mixed $name

    Provide a single configuration name as a string or multiple ones as an array which will be used to read from. Pass true to use all configurations.

  • string $category

    A (dot-delimeted) category.

  • string $locale

    A locale identifier.

  • array $options

    Valid options are:

    • 'scope': The scope to use.
    • 'lossy': Whether or not to use the compact and lossy format, defaults to true.



If available the requested data, else null.


	public static function read($name, $category, $locale, array $options = []) {
		$defaults = ['scope' => null, 'lossy' => true];
		$options += $defaults;

		$category = strtok($category, '.');
		$id = strtok('.');

		$names = $name === true ? array_keys(static::$_configurations) : (array) $name;
		$results = [];

		foreach (Locale::cascade($locale) as $cascaded) {
			foreach ($names as $name) {
				$adapter = static::adapter($name);

				if ($result = $adapter->read($category, $cascaded, $options['scope'])) {
					$results += $result;
		if ($options['lossy']) {
			array_walk($results, function(&$value) {
				$value = $value['translated'];

		if ($id) {
			return isset($results[$id]) ? $results[$id] : null;
		return $results ?: null;