Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the return.callbacksort translation about the word "an integer" from "数" to "整数" #84

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

koseki
Copy link
Contributor

@koseki koseki commented Mar 21, 2023

ソートの比較関数の戻り値が float だと int に変換されてしまい正しく動かないようなので、"an integer" の訳は「数」ではなく「整数」が適切ではないでしょうか。

https://github.com/php/doc-en/blob/6f9e433f4b4a591801c3a49fc459550ea1b5f613/language-snippets.ent#L761

<?php
$x = [
    ['score' => 8.5],
    ['score' => 9.2],
    ['score' => 8.4],
];

usort($x, function($a,$b) {
  return $b['score'] - $a['score'];
});
var_dump($x);

usort($x, function($a,$b) {
  return $b['score'] <=> $a['score'];
});
var_dump($x);
array(3) {
  [0]=>
  array(1) {
    ["score"]=>
    float(8.5)
  }
  [1]=>
  array(1) {
    ["score"]=>
    float(9.2)
  }
  [2]=>
  array(1) {
    ["score"]=>
    float(8.4)
  }
}
array(3) {
  [0]=>
  array(1) {
    ["score"]=>
    float(9.2)
  }
  [1]=>
  array(1) {
    ["score"]=>
    float(8.5)
  }
  [2]=>
  array(1) {
    ["score"]=>
    float(8.4)
  }
}

この挙動に関して、 usort() 関数から、以前あった注意書きが失われているようですが、これについては doc-en に issue (php/doc-en#2365) を作成しました。

…rom "数" to "整数"

The sort callback function doesn't work properly if it returns a float, so the translation should be "整数".
Copy link
Member

@mumumu mumumu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

報告ありがとうございます 🙏

@mumumu mumumu merged commit 7e5b447 into php:master Mar 21, 2023
@koseki koseki deleted the callbacksort-return-int branch March 21, 2023 23:54
@koseki
Copy link
Contributor Author

koseki commented Mar 24, 2023

@mumumu マージありがとうございました!

の修正がマージされたので、後ほど ja にも PR 出させていただければと思います。もし何か支障がありましたらご指摘ください。 🙇

@mumumu
Copy link
Member

mumumu commented Mar 24, 2023

後ほど ja にも PR 出させていただければと思います。

@koseki ありがとうございます!
支障ありませんので、PR お待ちしております 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants