Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add class for translation of dynamic elements: number of notes, reviews, etc.

未关闭
#1,070 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
php

调研方向

首先阅读 php/web-php#1057 中的讨论以及链接的 onlinephp.io 示例。确定当前如何呈现动态计数,以及哪些语言需要复数规则。当完成针对备注、评论和 upvote 等计数的语言特定格式化设计并实现后,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Feature

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:

https://onlinephp.io/c/bdfda

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', '&nbsp;',); // 8&nbsp;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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php/web-php 的其他 Issue

查看 php/web-php 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。