サポートするファイル形式(Strings)

.PHP - 配列 (Strings)

本コンテンツはPhrase Language AIの機械翻訳により、英語から翻訳されています。

ファイル拡張子

.php

API拡張

php_array

インポート

はい

エクスポート

はい

複数形のサポート

いいえ

説明のサポート

いいえ

配列とは、順序付けられた一覧、または項目の集合です。配列の項目は、PHPでは基本的にどのような型でも可能です:数値、文字列、オブジェクト、別の配列など。ロケールメッセージ配列の値として、よくStringsを使用します。 PHPの配列には、2つのメジャーな種類があります:

  • インデックス付き — これらの配列は暗黙的に順序付けられます。例:['red', 'green', 'blue']

  • 連想配列 — これらの配列には、キー(整数または文字列)と、それに関連付けられた値のペアが含まれます。例:['first_name' => 'Adam', 'last_name' => 'McMan', 'age' => 22]

配列要素の値は、初期化中、または配列自体の変数名を使用して設定できます。

<?php

// 初期化中

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

// 変数名を使用 

$my_second_array['key'] = 'value'

この値の設定方法は、組み合わせて使用できます。

配列の仕事

コマンドラインから取得する場合、メッセージファイルは、キーと値のペアを持つ連想配列を使用した以下のファイル形式で送信されます。

<?php

$lang['key'] = 'translated message';

$lang['another_key'] = 'Another translated message';

アプリがこの種類のファイル形式で仕事ができるように設定されていることを確認してください。メッセージファイルで匿名配列を返さないでください。また、メッセージ配列には $lang という名前を使用してください。

コードサンプル

<?php

$lang['boolean_key'] = '--- true
';
$lang['empty_string_translation'] = '';
$lang['key_with_description'] = 'Check it out!このキーは説明です。(少なくとも一部のファイル形式で)';
$lang['key_with_line-break'] = 'This translations contains
a line-break.';
$lang['nested.deeply.key'] = 'Wow, this キー is nested even deeper.';
$lang['nested.key'] = 'This key is nested inside a namespace.';
$lang['null_translation'] = '';
$lang['sample_collection'] = '---
- first item
- second item
- third item
';
$lang['simple_key'] = 'Just a simple key with a simple message.';
$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.