|
|
@ -157,19 +157,24 @@ class I18N extends Component |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (isset($this->translations[$category])) { |
|
|
|
if (isset($this->translations[$category])) { |
|
|
|
$source = $this->translations[$category]; |
|
|
|
$source = $this->translations[$category]; |
|
|
|
|
|
|
|
if ($source instanceof MessageSource) { |
|
|
|
|
|
|
|
return $source; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return $this->translations[$category] = Yii::createObject($source); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// try wildcard matching |
|
|
|
// try wildcard matching |
|
|
|
foreach ($this->translations as $pattern => $config) { |
|
|
|
foreach ($this->translations as $pattern => $config) { |
|
|
|
if ($pattern === '*' || substr($pattern, -1) === '*' && strpos($category, rtrim($pattern, '*')) === 0) { |
|
|
|
if ($pattern === '*' || substr($pattern, -1) === '*' && strpos($category, rtrim($pattern, '*')) === 0) { |
|
|
|
$source = $config; |
|
|
|
if ($config instanceof MessageSource) { |
|
|
|
break; |
|
|
|
return $config; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return $this->translations[$category] = $this->translations[$pattern] = Yii::createObject($config); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($source)) { |
|
|
|
|
|
|
|
return $source instanceof MessageSource ? $source : Yii::createObject($source); |
|
|
|
throw new InvalidConfigException("Unable to locate message source for category '$category'."); |
|
|
|
} else { |
|
|
|
|
|
|
|
throw new InvalidConfigException("Unable to locate message source for category '$category'."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|