{JA} - 3.4.6 カスタムインフレクション(Custom Inflections)

Cakeの命名規約は非常に便利です。データベースのテーブルを、big_boxes、モデルをBigBox、コントローラをBigBoxesControllerとすることができ、それですべてが自動的に協調するようになります。CakePHPがすべてをつなぎ合わせることができるのは、単語の単数形と複数形をinflecting(語尾変化、屈折)させているからです。

CakePHPのinflector(複数形化、単数形化、キャメルケース化、アンダースコア化するクラス)がうまく動かない場合があります。(特に英語圏以外)CakePHPがFociをFishだと分からないのであれば、カスタムinflection設定ファイルを編集しましょう。ここに独自のルールを書いて、CakePHPに教えることができます。このファイルは、/app/config/inflections.phpにあります。

このファイルの中には六つの変数があります。各変数によって、CakePHPのinflectionの振る舞いを調整できます。

inflections.php 変数 説明
$pluralRules この配列には、複数形にするためのルールが含まれます。配列のキーがパターンで、値が置き換える値になります。
$uninflectedPlural 複数形にする必要のない単語を含む配列です。(質量名詞など)
$irregularPlural 単語とその複数形を含む配列です。配列のキーは単数形で、値が複数形です。この配列は、$pluralRulesで定義されているルールに従わない単語を指定するのに用いられます。
$singularRules $pluralRulesと同じで、この配列だけが単数形化する単語を持っています。
$uninflectedSingular $uninflectedPluralと同じで、この配列だけが、単数形を持たない単語を持っています。デフォルトでは、$uninflectedPluralと同じです。
$irregularSingular $irregularPluralと同じ形式で、単数形の単語だけです。

{EN} - 3.4.6 Custom Inflections

Cake's naming conventions can be really nice - you can name your database table big_boxes, your model BigBox, your controller BigBoxesController, and everything just works together automatically. The way CakePHP knows how to tie things together is by inflecting the words between their singular and plural forms.

There are occasions (especially for our non-English speaking friends) where you may run into situations where CakePHP's inflector (the class that pluralizes, singularizes, camelCases, and under_scores) might not work as you'd like. If CakePHP won't recognize your Foci or Fish, editing the custom inflections configuration file is where you can tell CakePHP about your special cases. This file is found in /app/config/inflections.php.

In this file, you will find six variables. Each allows you to fine-tune CakePHP inflection behavior.

inflections.php Variable Description
$pluralRules This array contains regular expression rules for pluralizing special cases. The keys of the array are patterns, and the values are replacements.
$uninflectedPlural An array containing words that do not need to be modified in order to be plural (mass nouns, etc.).
$irregularPlural An array containing words and their plurals. The keys of the array contain the singular form, the values, plural forms. This array should be used to store words that don’t follow rules defined in $pluralRules.
$singularRules Same as with $pluralRules, only this array holds rules that singularize words.
$uninflectedSingular Same as with $uninflectedPlural, only this array holds words that have no singular form. This is set equal to $uninflectedPlural by default.
$irregularSingular Same as with $irregularPlural, only with words in singular form.

Differences

Lines: 1-68Lines: 1-67
-<title>Custom Inflections</title> +<title>カスタムインフレクション(Custom Inflections</title>
 <p> <p>
- Cake's naming conventions can be really nice - you can name your database table big_boxes, your model BigBox, your controller BigBoxesController, and everything just works together automatically. The way CakePHP knows how to tie things together is by <em>inflecting</em> the words between their singular and plural forms. + Cakeの命名規約は非常に便利です。データベースのテーブルを、big_boxes、モデルをBigBox、コントローラをBigBoxesControllerとすることができ、それですべてが自動的に協調するようになります。CakePHPがすべてをつなぎ合わせることができるのは、単語の単数形と複数形を<em>inflecting(語尾変化、屈折)</em>させているからです。
 </p> </p>
 <p> <p>
- There are occasions (especially for our non-English speaking friends) where you may run into situations where CakePHP's inflector (the class that pluralizes, singularizes, camelCases, and under_scores) might not work as you'd like. If CakePHP won't recognize your Foci or Fish, editing the custom inflections configuration file is where you can tell CakePHP about your special cases. This file is found in /app/config/inflections.php. + CakePHPinflector(複数形化、単数形化、キャメルケース化、アンダースコア化するクラス)がうまく動かない場合があります。(特に英語圏以外)CakePHPFociFishだと分からないのであれば、カスタムinflection設定ファイルを編集しましょう。ここに独自のルールを書いて、CakePHPに教えることができます。このファイルは、/app/config/inflections.phpにあります。
 </p> </p>
 <p> <p>
- In this file, you will find six variables. Each allows you to fine-tune CakePHP inflection behavior. + このファイルの中には六つの変数があります。各変数によって、CakePHPinflectionの振る舞いを調整できます。
 </p> </p>
 <table> <table>
  <tr>  <tr>
  <th>  <th>
- inflections.php Variable + inflections.php 変数
  </th>  </th>
  <th>  <th>
- Description
</th>
+ 説明 </th>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  $pluralRules  $pluralRules
  </td>  </td>
  <td>  <td>
- This array contains regular expression rules for pluralizing special cases. The keys of the array are patterns, and the values are replacements. + この配列には、複数形にするためのルールが含まれます。配列のキーがパターンで、値が置き換える値になります。
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  $uninflectedPlural  $uninflectedPlural
  </td>  </td>
  <td>  <td>
- An array containing words that do not need to be modified in order to be plural (mass nouns, etc.). + 複数形にする必要のない単語を含む配列です。(質量名詞など)
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  $irregularPlural  $irregularPlural
  </td>  </td>
  <td>  <td>
- An array containing words and their plurals. The keys of the array contain the singular form, the values, plural forms. This array should be used to store words that dont follow rules defined in $pluralRules. + 単語とその複数形を含配列で。配列のキーは単数形で、値が複数形です。この配列は、$pluralRulesで定義されているルールに従わない単語を指定するのに用いられます。
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  $singularRules  $singularRules
  </td>  </td>
  <td>  <td>
- Same as with $pluralRules, only this array holds rules that singularize words. + $pluralRulesと同じで、この配列だけが単数形化する単語を持っています。
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  $uninflectedSingular  $uninflectedSingular
  </td>  </td>
  <td>  <td>
- Same as with $uninflectedPlural, only this array holds words that have no singular form. This is set equal to $uninflectedPlural by default. + $uninflectedPluralと同じで、この配列だけが、単数形を持たない単語を持っています。デフォルトでは、$uninflectedPluralと同じです。
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  $irregularSingular  $irregularSingular
  </td>  </td>
  <td>  <td>
- Same as with $irregularPlural, only with words in singular form. + $irregularPluralと同じ形式で、単数形の単語だけです。
  </td>  </td>
  </tr>  </tr>
 </table> </table>