本文整理匯總了PHP中Cake\Utility\Inflector::delimit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::delimit方法的具體用法?PHP Inflector::delimit怎麽用?PHP Inflector::delimit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\Utility\Inflector
的用法示例。
在下文中一共展示了Inflector::delimit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getLocalizedFieldnames
/**
* Retrieve field names as localized, comma seperated string.
*
* @param ModelHistory $historyEntry A History entry
* @return string
*/
public function getLocalizedFieldnames(ModelHistory $historyEntry)
{
$fields = join(', ', array_map(function ($value) use($historyEntry) {
if (!is_string($value)) {
return $value;
}
// Get pre configured translations and return it if found
$fields = TableRegistry::get($historyEntry->model)->getFields();
if (isset($fields[$value]['translation'])) {
return $fields[$value]['translation'];
}
// Try to get the generic model.field translation string
$localeSlug = strtolower(Inflector::singularize(Inflector::delimit($historyEntry->model))) . '.' . strtolower($value);
$translatedString = __($localeSlug);
// Return original value when no translation was made
if ($localeSlug == $translatedString) {
return $value;
}
return $translatedString;
}, array_keys($historyEntry->data)));
return $fields;
}