Skip to content

use native-time-ago#236

Open
chinesepowered wants to merge 1 commit intonmn:masterfrom
chinesepowered:use-native-time
Open

use native-time-ago#236
chinesepowered wants to merge 1 commit intonmn:masterfrom
chinesepowered:use-native-time

Conversation

@chinesepowered
Copy link

Summary

This PR replaces the bundled language strings with native-time-ago, a zero-dependency library that uses the native Intl.RelativeTimeFormat API.

Benefits:

  • ✅ Zero dependencies (removes 70+ bundled locale files)
  • ✅ Supports 100+ languages automatically via browser's native API
  • ✅ Translations improve as browsers update (no locale maintenance)
  • ✅ Smaller bundle size

Changes:

  • Added native-time-ago@1.0.1 dependency
  • Updated component to use Intl.RelativeTimeFormat with numeric: 'auto' for natural strings like "yesterday" instead of "1 day ago"
  • Added locale prop (defaults to 'en')
  • Auto-updates every 60 seconds when live={true}
    Migration: The API is nearly identical. Usage like <TimeAgo date={date} locale="es" /> works the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant