Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
28 lines (24 loc) · 1.08 KB

File metadata and controls

28 lines (24 loc) · 1.08 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

String Utilities

Implementation Guidelines

Pluralization

  • Consider all cases when implementing word transformations:
    • Zero quantity may need special handling
    • Negative numbers
    • Decimal numbers
    • Language/locale specific rules
    • Irregular plurals (e.g., child -> children)
    • Words ending in y: only change to 'ies' if preceded by a consonant (e.g., "fly" -> "flies" but "day" -> "days", "key" -> "keys")
    • Words ending in s, ch, sh, x: add 'es'
    • Special suffixes (-es, -ies)

Simple implementations can lead to bugs. Prefer using established i18n/l10n libraries for production text transformations.

General String Transformation Guidelines

  • Avoid quick, simple implementations for language-specific transformations
  • Consider edge cases before implementing string manipulation functions
  • Document assumptions and limitations in comments
  • For text displayed to users, use i18n libraries rather than custom implementations
  • Test with a variety of inputs including:
    • Empty strings
    • Special characters
    • Unicode/emoji
    • Very long strings
    • Different locales
Morty Proxy This is a proxified and sanitized view of the page, visit original site.