Skip to content

Commit 06a883e

Browse files
committed
laravel 5.1 function translation
1 parent 0755d7c commit 06a883e

File tree

2 files changed

+85
-37
lines changed

2 files changed

+85
-37
lines changed

index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,8 +1698,6 @@ <h6>Arrays</h6>
16981698
array_only($array, array('key'));
16991699
// Return array of key => values
17001700
array_pluck($array, 'key');
1701-
// Will push an item onto the beginning of an array
1702-
array_prepend($array, 'zero');
17031701
// Return and remove 'key' from array
17041702
array_pull($array, 'key');
17051703
// Set an array item to a given value using "dot" notation
@@ -1792,8 +1790,6 @@ <h6>Miscellaneous</h6>
17921790
$token = csrf_token();
17931791
// Dumps the given variable and ends execution of the script
17941792
dd($value);
1795-
// Pushes a new job onto the Laravel job queue
1796-
dispatch(new App\Jobs\SendEmails);
17971793
// Gets the value of an environment variable or returns a default value
17981794
$env = env('APP_ENV');
17991795
$env = env('APP_ENV', 'production');

index_zh-CN.html

Lines changed: 85 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,30 +1667,33 @@ <h4><a name="str" href="#str">String</a> <a href="http://laravel-china.org/docs/
16671667
</section>
16681668

16691669
<section class="cmd-description grid-item">
1670-
<h4><a name="helpers" href="#helpers">Helper</a> <a href="http://laravel-china.org/docs/5.1/helpers" title="Helpers @ Laravel Docs"><i class="icon-file-text"></i></a></h4>
1671-
<h6>Arrays</h6>
1670+
<h4><a name="helpers" href="#helpers">帮助函数</a> <a href="http://laravel.com/docs/helpers" title="Helpers @ Laravel Docs"><i class="icon-file-text"></i></a></h4>
1671+
<h6>数组</h6>
16721672
<pre class="prettyprint lang-php">
1673+
// 如果给定的键不存在于该数组,array_add 函数将给定的键值对加到数组中
16731674
array_add($array, 'key', 'value');
1674-
// 使用回调来构建一个新数组
1675-
array_build($array, function(){});
1676-
// 将两个数组一分为二, 一个为 key, 另一个为 value
1675+
// 将数组的每一个数组折成单一数组
1676+
array_collapse($array);
1677+
// 函数返回两个数组,一个包含原本数组的键,另一个包含原本数组的值
16771678
array_divide($array);
1678-
// 把一个多维数组扁平化,使用「.」符号做链式读取
1679+
// 把多维数组扁平化成一维数组,并用「点」式语法表示深度
16791680
array_dot($array);
1680-
// 获取除了指定数组的数组内容
1681+
// 从数组移除给定的键值对
16811682
array_except($array, array('key'));
1682-
// 通过给定的真实测试来返回数组的第一个元素
1683+
// 返回数组中第一个通过为真测试的元素
16831684
array_first($array, function($key, $value){}, $default);
16841685
// 将多维数组扁平化成一维
1685-
array_flatten($array);
1686-
// 通过点符号来移除一条或多条数组条目
1686+
// ['Joe', 'PHP', 'Ruby'];
1687+
array_flatten(['name' => 'Joe', 'languages' => ['PHP', 'Ruby']]);
1688+
// 以「点」式语法从深度嵌套数组移除给定的键值对
16871689
array_forget($array, 'foo');
1688-
// 点符号
16891690
array_forget($array, 'foo.bar');
16901691
// 使用「点」式语法从深度嵌套数组取回给定的值
16911692
array_get($array, 'foo', 'default');
16921693
array_get($array, 'foo.bar', 'default');
1693-
// 从数组返回给定的键值
1694+
// 使用「点」式语法检查给定的项目是否存在于数组中
1695+
array_has($array, 'products.desk');
1696+
// 从数组返回给定的键值对
16941697
array_only($array, array('key'));
16951698
// 从数组拉出一列给定的键值对
16961699
array_pluck($array, 'key');
@@ -1701,52 +1704,64 @@ <h6>Arrays</h6>
17011704
array_set($array, 'key.subkey', 'value');
17021705
// 借由给定闭包结果排序数组
17031706
array_sort($array, function(){});
1704-
// 数组的第一个元素
1707+
// 使用 sort 函数递归排序数组
1708+
array_sort_recursive();
1709+
// 使用给定的闭包过滤数组
1710+
array_where();
1711+
// 返回给定数组的第一个元素
17051712
head($array);
1706-
// 数组的最后一个元素
1713+
// 返回给定数组的最后一个元素
17071714
last($array);
17081715
</pre>
1709-
<h6>Paths</h6>
1716+
<h6>路径</h6>
17101717
<pre class="prettyprint lang-php">
17111718
// 取得 app 文件夹的完整路径
17121719
app_path();
1713-
1714-
// 获取公开文件夹的路径
1715-
public_path();
1716-
// App root path
1717-
// App 的根路径
1720+
// 取得项目根目录的完整路径
17181721
base_path();
1719-
// Get the path to the storage folder
1720-
// 获取存储文件夹路径
1722+
// 取得应用配置目录的完整路径
1723+
config_path();
1724+
// 取得应用数据库目录的完整路径
1725+
database_path();
1726+
// 取得加上版本号的 Elixir 文件路径
1727+
elixir();
1728+
// 取得 public 目录的完整路径
1729+
public_path();
1730+
// 取得 storage 目录的完整路径
17211731
storage_path();
17221732
</pre>
1723-
<h6>Strings</h6>
1733+
<h6>字符串</h6>
17241734
<pre class="prettyprint lang-php">
1725-
// 会将给定的字符串转换成 驼峰式命名
1735+
// 将给定的字符串转换成 驼峰式命名
17261736
camel_case($value);
1727-
// 获取不包含命名空间的类名称
1737+
// 返回不包含命名空间的类名称
17281738
class_basename($class);
1739+
class_basename($object);
17291740
// 对给定字符串运行 htmlentities
17301741
e('&lt;html&gt;');
17311742
// 判断字符串开头是否为给定内容
17321743
starts_with('Foo bar.', 'Foo');
17331744
// 判断给定字符串结尾是否为指定内容
17341745
ends_with('Foo bar.', 'bar.');
1735-
// 将给定的字符串转换成蛇形命名
1746+
// 将给定的字符串转换成 蛇形命名
17361747
snake_case('fooBar');
1748+
// 限制字符串的字符数量
1749+
str_limit();
17371750
// 判断给定字符串是否包含指定内容
17381751
str_contains('Hello foo bar.', 'foo');
1739-
// 添加给定内容到字符串结尾
1752+
// 添加给定内容到字符串结尾,foo/bar/
17401753
str_finish('foo/bar', '/');
1741-
// 判断给定的字符串与给定的格式是否符合。星号可作为通配符使用
1754+
// 判断给定的字符串与给定的格式是否符合
17421755
str_is('foo*', 'foobar');
1743-
// 转换字符串成复数形。该函数目前仅支持英文
1756+
// 转换字符串成复数形
17441757
str_plural('car');
17451758
// 产生给定长度的随机字符串
17461759
str_random(25);
17471760
// 转换字符串成单数形。该函数目前仅支持英文
17481761
str_singular('cars');
1749-
// 将给定字符串转换成 「首字大写命名」 结果: FooBar
1762+
// 从给定字符串产生网址友善的「slug」
1763+
str_slug("Laravel 5 Framework", "-");
1764+
// 将给定字符串转换成「首字大写命名」: FooBar
17501765
studly_case('foo_bar');
17511766
// 根据你的本地化文件翻译给定的语句
17521767
trans('foo.bar');
@@ -1768,14 +1783,51 @@ <h6>URLs and Links</h6>
17681783
</pre>
17691784
<h6>Miscellaneous</h6>
17701785
<pre class="prettyprint lang-php">
1786+
// 返回一个认证器实例。你可以使用它取代 Auth facade
1787+
auth()->user();
1788+
// 产生一个重定向回应让用户回到之前的位置
1789+
back();
1790+
// 使用 Bcrypt 哈希给定的数值。你可以使用它替代 Hash facade
1791+
bcrypt('my-secret-password');
1792+
// 从给定的项目产生集合实例
1793+
collect(['taylor', 'abigail']);
1794+
// 取得设置选项的设置值
1795+
config('app.timezone', $default);
1796+
// 产生包含 CSRF 令牌内容的 HTML 表单隐藏字段
1797+
{!! csrf_field() !!}
17711798
// 取得当前 CSRF 令牌的内容
1772-
csrf_token();
1799+
$token = csrf_token();
17731800
// 输出给定变量并结束脚本运行
17741801
dd($value);
1802+
// 取得环境变量值或返回默认值
1803+
$env = env('APP_ENV');
1804+
$env = env('APP_ENV', 'production');
1805+
// 配送给定事件到所属的侦听器
1806+
event(new UserRegistered($user));
1807+
// 根据给定类、名称以及总数产生模型工厂建构器
1808+
$user = factory(App\User::class)->make();
1809+
// 产生拟造 HTTP 表单动作内容的 HTML 表单隐藏字段
1810+
{!! method_field('delete') !!}
1811+
// 取得快闪到 session 的旧有输入数值
1812+
$value = old('value');
1813+
$value = old('value', 'default');
1814+
// 返回重定向器实例以进行 重定向
1815+
return redirect('/home');
1816+
// 取得目前的请求实例或输入的项目
1817+
$value = request('key', $default = null)
1818+
// 创建一个回应实例或获取一个回应工厂实例
1819+
return response('Hello World', 200, $headers);
1820+
// 可被用于取得或设置单一 session 内容
1821+
$value = session('key');
1822+
// 在没有传递参数时,将返回 session 实例
1823+
$value = session()->get('key');
1824+
session()->put('key', $value);
17751825
// 返回给定数值
17761826
value(function(){ return 'bar'; });
1777-
// with 函数返回给定的数值。该函数主要用于方法炼结(method chaining),除此之外不太可能用到
1778-
with(new Foo)->chainedMethod();
1827+
// 取得视图 实例
1828+
return view('auth.login');
1829+
// 返回给定的数值
1830+
$value = with(new Foo)->work();
17791831
</pre>
17801832
</div>
17811833
</div>

0 commit comments

Comments
 (0)