protected function resolveAliases($data, $currentPath)
    {
        if (!is_array($data)) {
            return $data;
        }

        foreach ($data as $nodeString => $nodeChildren) {
            if (self::getNodeName($nodeString) === 'alias') {
                if (self::getAttributeValue($nodeString, 'source') !== 'locale') {
                    // Value of source attribute can be 'locale' or particular locale identifier, but we do not support the second mode, ignore it silently
                    break;
                }

                $sourcePath = self::getAttributeValue($nodeString, 'path');

                // Change relative path to absolute one
                $sourcePath = str_replace('../', '', $sourcePath, $countOfJumpsToParentNode);
                $sourcePath = str_replace('\'', '"', $sourcePath);
                $currentPathNodeNames = explode('/', $currentPath);
                for ($i = 0; $i < $countOfJumpsToParentNode; ++$i) {
                    unset($currentPathNodeNames[count($currentPathNodeNames) - 1]);
                }
                $sourcePath = implode('/', $currentPathNodeNames) . '/' . $sourcePath;

                unset($data[$nodeString]);
                $sourceData = $this->getRawData($sourcePath);
                if (is_array($sourceData)) {
                    $data = array_merge($sourceData, $data);
                }
                break;
            } else {
                $data[$nodeString] = $this->resolveAliases($data[$nodeString], ($currentPath === '') ? $nodeString : ($currentPath . '/' . $nodeString));
            }
        }

        return $data;
    }
protected function resolveAliases($data, $currentPath)
    {
        if (!is_array($data)) {
            return $data;
        }

        foreach ($data as $nodeString => $nodeChildren) {
            if (self::getNodeName($nodeString) === 'alias') {
                if (self::getAttributeValue($nodeString, 'source') !== 'locale') {
                    // Value of source attribute can be 'locale' or particular locale identifier, but we do not support the second mode, ignore it silently
                    break;
                }

                $sourcePath = self::getAttributeValue($nodeString, 'path');

                // Change relative path to absolute one
                $sourcePath = str_replace('../', '', $sourcePath, $countOfJumpsToParentNode);
                $sourcePath = str_replace('\'', '"', $sourcePath);
                $currentPathNodeNames = explode('/', $currentPath);
                for ($i = 0; $i < $countOfJumpsToParentNode; ++$i) {
                    unset($currentPathNodeNames[count($currentPathNodeNames) - 1]);
                }
                $sourcePath = implode('/', $currentPathNodeNames) . '/' . $sourcePath;

                unset($data[$nodeString]);
                $sourceData = $this->getRawData($sourcePath);
                if (is_array($sourceData)) {
                    $data = array_merge($sourceData, $data);
                }
                break;
            } else {
                $data[$nodeString] = $this->resolveAliases($data[$nodeString], ($currentPath === '') ? $nodeString : ($currentPath . '/' . $nodeString));
            }
        }

        return $data;
    }
protected function resolveAliases ( $ data , $ currentPath ) { if ( ! is_array ( $ data ) ) { return $ data ; } foreach ( $ data as $ nodeString => $ nodeChildren ) { if ( self :: getNodeName ( $ nodeString ) === 'alias' ) { if ( self :: getAttributeValue ( $ nodeString , 'source' ) !== 'locale' ) { // Value of source attribute can be 'locale' or particular locale identifier, but we do not support the second mode, ignore it silently break ; } $ sourcePath = self :: getAttributeValue ( $ nodeString , 'path' ) ; // Change relative path to absolute one $ sourcePath = str_replace ( '../' , '' , $ sourcePath , $ countOfJumpsToParentNode ) ; $ sourcePath = str_replace ( '\'' , '"' , $ sourcePath ) ; $ currentPathNodeNames = explode ( '/' , $ currentPath ) ; for ( $ i = 0 ; $ i < $ countOfJumpsToParentNode ; ++ $ i ) { unset ( $ currentPathNodeNames [ count ( $ currentPathNodeNames ) - 1 ] ) ; } $ sourcePath = implode ( '/' , $ currentPathNodeNames ) . '/' . $ sourcePath ; unset ( $ data [ $ nodeString ] ) ; $ sourceData = $ this -> getRawData ( $ sourcePath ) ; if ( is_array ( $ sourceData ) ) { $ data = array_merge ( $ sourceData , $ data ) ; } break ; } else { $ data [ $ nodeString ] = $ this -> resolveAliases ( $ data [ $ nodeString ] , ( $ currentPath === '' ) ? $ nodeString : ( $ currentPath . '/' . $ nodeString ) ) ; } } return $ data ; }
Resolves any 'alias' nodes in parsed CLDR data.

CLDR uses 'alias' tag which denotes places where data should be copied
from. This tag has 'source' attribute pointing (by relative XPath query)
to the source node - it should be copied with all it's children.

@param mixed $data Part of internal array to resolve aliases for (string if leaf, array otherwise)
@param string $currentPath Path to currently analyzed part of data
@return mixed Modified (or unchanged) $data
@throws Exception\InvalidCldrDataException When found alias tag which has unexpected structure
Resolves any alias nodes in parsed CLDR data .