Add class for translation of dynamic elements: number of notes, reviews, etc.
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- php
调研方向
首先阅读 php/web-php#1057 中的讨论以及链接的 onlinephp.io 示例。确定当前如何呈现动态计数,以及哪些语言需要复数规则。当完成针对备注、评论和 upvote 等计数的语言特定格式化设计并实现后,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Base on: https://github.com/php/web-php/pull/1057#discussion_r1748003699
I suggest add methods for different languages to form on doc-site correct plurals for different dynamic elements: the total note count, the number of upvotes, etc.
Maybe something like this:
Contributors from each country will only have to implement their plural method and call in the code:
<?php
$num_notes = 1;
echo NumberBaseDeclinsion::decline($num_notes, ['note', 'notes',], 'en',); // 1 note
echo NumberBaseDeclinsion::decline($num_notes, ['заметка', 'заметки', 'заметок',], 'ru',); // 1 заметка
$num_notes = 2;
echo NumberBaseDeclinsion::decline($num_notes, ['note', 'notes',], 'en',); // 2 notes
echo NumberBaseDeclinsion::decline($num_notes, ['заметка', 'заметки', 'заметок',], 'ru',); // 2 заметки
$num_notes = 5;
echo NumberBaseDeclinsion::decline($num_notes, ['note', 'notes',], 'en',); // 5 notes
echo NumberBaseDeclinsion::decline($num_notes, ['заметка', 'заметки', 'заметок',], 'ru',); // 5 заметок
// Phrase
echo NumberBaseDeclinsion::decline(38, ['pink flamingo', 'pink flamingos',], 'en',); // 38 pink flamingos
echo NumberBaseDeclinsion::decline(38, ['розовый фламинго', 'розовых фламинго', 'розовых фламинго',], 'ru',); // 38 розовых фламинго
// And if you want the text not to break between the number and the next word, you can add an unbreakable space:
echo NumberBaseDeclinsion::decline(8, ['comment', 'comments',], 'en', ' ',); // 8 comments
More examples can be found at the link.
In particular, if you translate the total number of notes of the contribution notes, then for the Russian language you will need 1 singular form + 2 plural forms. And for English, only two forms are enough. Therefore, a separate method (or function, if it is decided to write in a functional style) will be required for each language, which will form the correct string with a number for its language
- 主要语言
- PHP
- 星标
- 1.1k
- 派生
- 641
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 19
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
php/web-php 的其他 Issue
-
Bug Status: Needs Triage
难度 2/5 1-3 小时 新手友好度 75/100
-
Page: downloads
难度 3/5 1-2 天 新手友好度 55/100
-
Page: downloads
难度 3/5 1-2 天 新手友好度 62/100
-
Bug Status: Needs Triage
难度 3/5 1-2 天 新手友好度 55/100
相似的 Issue
-
Bug
难度 2/5 1-3 小时 新手友好度 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
难度 2/5 1-3 小时 新手友好度 75/100
-
HttpClient
难度 2/5 1-3 小时 新手友好度 75/100
symfony/symfony-docs#23092 ·
-
sync-en
难度 1/5 1 小时以内 新手友好度 90/100
-
sync-en
难度 1/5 1 小时以内 新手友好度 95/100