-
Notifications
You must be signed in to change notification settings - Fork 552
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
Add function for translation of UI elements #1057
Conversation
🚀 Preview for commit 9a1fd55 can be found at https://web-php-pr-1057.preview.thephp.foundation |
I don't quite know what to make of this test failure and visual diff in the above link as both pages seem the same to me. If I understand this correctly, they're off by 40 pixels somewhere. Any pointers on what to do with this would be welcome. |
really weird, the since the test environment only uses English, maybe make some other language as default to see how it works, |
@@ -59,17 +62,19 @@ function manual_notes($notes):void { | |||
$noteCountHtml = "<span class=\"count\">$num_notes note" . ($num_notes == 1 ? '' : 's') . "</span>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
$noteCountHtml = "<span class=\"count\">$num_notes " . ($num_notes == 1 ? $note : $notes) . "</span>";
to allow translation of the number of notes beside the title?
$note = 'note';
$notes = 'notes';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would be much better! Appending an "s" works for few languages. However, pluralization is more difficult than distinguishing between singular and plural (@mvorisek can probably confirm for the Czech language), but it might be okay for the currently active languages (and we could still extend).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm appending s
to make words plular is NOT how Czech language works. We change the word ending based on many rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for Italian the plurals are not formed by appending s
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use the more universal format «notes: N»,
because, for example, in Russian (I guess it's not the only language),
different endings will be for 1, 3, and 5 notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because, for example, in Russian (I guess it's not the only language),
different endings will be for 1, 3, and 5 notes.
That's what I was referring to regarding the Czech language. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why gettext
has ngettext()
, but maybe using that would be overkill for this issue. If there was interest in doing more widespread internationalization of the PHP website, that could be a way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
$noteCountHtml = "<span class=\"count\">$num_notes " . ($num_notes == 1 ? $note : $notes) . "</span>";
to allow translation of the number of notes beside the title?
I think that doing this is a good idea but I would prefer not to do it as part of this PR. The changes in this PR address the simpler issue of translating the static elements of the documentation UI. Looking at the above discussion on the intricacies of translating the number of notes to various languages (and we haven't even heard from the Chinese or Japanese doc maintainers on the subject), I think all that needs a bit more thought put into it and should be split into its own PR.
So my suggestion is for this PR to only address the translation of the static elements of the doc pages and to open a new PR for the dynamic elements. Maybe even open an issue first and ask maintainers of every language repo to discuss how the dynamic elements (the total note count, the number of upvotes/downvotes and how long ago a note was submitted) can be translated to each of their respective languages and open a PR once it is clear how to adequately implement it for each of those languages.
If merging this PR with the translation of only the static UI elements is acceptable, should the actual translations be done as part of this PR (as was done with the Russian translation by @saundefined and @mmalferov) or as separate PRs? |
In my opinion, this is good enough. |
628a288
to
ed8da8f
Compare
🚀 Regression report for commit 9a1fd55 is at https://web-php-regression-report-pr-1057.preview.thephp.foundation |
Rebased the PR so it can be merged which, if there are no objections, I'd like to do around the end of next week. |
There were no objections in the past few weeks, so I'd like to have this merged later on today/tomorrow. |
Add a function similar to the one in PhD that can be used to translate words or phrases, and use it to translate UI elements of the doc pages. If translation of a certain text is not defined for a language, the function will use the original English text.
Closes php/phd#145
As noted in this comment (by @derickr ?) the "User Contributed Notes" related parts of the UI may have not been translated on purpose.
Pinging @leonardolara and @cmb69 from the original issue.