本文整理汇总了PHP中Helpers::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::translate方法的具体用法?PHP Helpers::translate怎么用?PHP Helpers::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::translate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: items
/**
* Creates a serie of checkable items
*
* @param array $_items Items to create
*/
protected function items($_items)
{
// If passing an array
if (sizeof($_items) == 1 and is_array($_items[0])) {
$_items = $_items[0];
}
// Iterate through items, assign a name and a label to each
$count = 0;
foreach ($_items as $name => $label) {
// If we haven't any name defined for the checkable, try to compute some
if (!is_string($name)) {
$name = $this->name;
if ($this->checkable == 'checkbox') {
$name .= '_' . $count;
}
}
$this->items[] = array('name' => $name, 'label' => Helpers::translate($label));
$count++;
}
}
示例2: legend
/**
* Creates a form legend
*
* @param string $legend The text
* @param array $attributes Its attributes
* @return string A legend tag
*/
public static function legend($legend, $attributes = array())
{
$legend = Helpers::translate($legend);
return '<legend' . \HTML::attributes($attributes) . '>' . $legend . '</legend>';
}
示例3: items
/**
* Creates a serie of checkable items
*
* @param array $_items Items to create
*/
protected function items($_items)
{
// If passing an array
if (sizeof($_items) == 1 and is_array($_items[0])) {
$_items = $_items[0];
}
// Iterate through items, assign a name and a label to each
$count = 0;
foreach ($_items as $label => $name) {
// Define a fallback name in case none is found
$fallback = $this->isCheckbox() ? $this->name . '_' . $count : $this->name;
// If we haven't any name defined for the checkable, try to compute some
if (!is_string($label) and !is_array($name)) {
$label = $name;
$name = $fallback;
}
// If we gave custom information on the item, add them
if (is_array($name)) {
$attributes = $name;
$name = array_get($attributes, 'name', $fallback);
unset($attributes['name']);
}
// Store all informations we have in an array
$item = array('name' => $name, 'label' => Helpers::translate($label));
if (isset($attributes)) {
$item['attributes'] = $attributes;
}
$this->items[] = $item;
$count++;
}
}
示例4: ponder
/**
* Ponders a label and a field name, and tries to get the best out of it
*
* @param string $label A label
* @param string $name A field name
* @return array A label and a field name
*/
private function ponder($name, $label)
{
// Check for the two possibilities
if ($label and !$name) {
$name = \Str::slug($label);
} elseif (!$label and $name) {
$label = $name;
}
// Attempt to translate the label
$label = Helpers::translate($label);
// Save values
$this->name = $name;
$this->label = $label;
}