支持文件类型 (Strings)

.PHP - Array (Strings)

文本由 Phrase Language AI 从英语机器翻译而得。

文件扩展名

.php

API 扩展

php_array

导入

导出

复数形式支持

描述支持

数组是有序的列表或项目集合。数组的项目可以是 PHP 中的任何类型:数字、字符串、对象、另一个数组等。我们经常在区域消息数组中使用字符串作为值。 PHP 数组有两种主要类型:

  • 索引 — 这些数组是隐式有序的,例如 ['red', 'green', 'blue']

  • 关联 — 这些数组包含键(可以是整数或字符串)和相关值的对,例如 ['first_name' => 'Adam', 'last_name' => 'McMan', 'age' => 22]

数组元素的值可以在初始化时设置,也可以使用数组本身的变量名。

<?php

// during initialization

$my_array = ['foo' => 'bar'];

// using variable name 

$my_second_array['key'] = 'value'

这种设置值的方法可以混合使用。

处理数组

从命令行提取时,消息文件将以以下格式发送,使用关联命名数组。

<?php

$lang['key'] = '翻译的消息';

$lang['another_key'] = '另一个翻译的消息';

确保应用程序已设置为使用这种格式。不要在消息文件中返回匿名数组,并使用名称 $lang 作为消息数组。

代码示例

<?php

$lang['boolean_key'] = '--- true
';
$lang['empty_string_translation'] = '';
$lang['key_with_description'] = '看看吧!"This key has a description!(至少在某些格式中)';
$lang['key_with_line-break'] = '此翻译包含
a line-break.';
$lang['nested.deeply.key'] = '哇,这个键嵌套得更深了。';
$lang['nested.key'] = '这个键嵌套在一个命名空间内。';
$lang['null_translation'] = '';
$lang['sample_collection'] = '---
- first item
- second item
- third item
';
$lang['simple_key'] = '只是一个简单的键,带有简单的信息。';
$lang['unverified_key'] = '这个翻译尚未验证,正在等待。(在某些格式中,我们也导出此状态)';
这篇文章有帮助吗?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.