php / php/web-php

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

Aperta
#1,070 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Feature
Lingua principale
PHP
Stelle
1.1k
Fork
641
Merge medio
22h 36m
PR unite (30g)
16

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo la discussione in php/web-php#1057 e gli esempi onlinephp.io collegati. Identifica come vengono attualmente visualizzati i conteggi dinamici e quali lingue necessitano di regole per il plurale. Il lavoro sarà considerato completato quando saranno disponibili un design concordato e un’implementazione per la formattazione specifica per lingua di conteggi come note, recensioni e upvote.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
internationalization, localization
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.