패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.1

humanize

Humanize는 UI 문자열이 자연스럽게 느껴지도록 도와주는 컴팩트한 툴킷입니다. 영어와 프랑스어로 된 날짜, 숫자, 목록 및 텍스트를 위한 보조 기능을 통해 원시 데이터와 인간 친화적인 표현 사이를 연결합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.7천
좋아요
33
Pub 점수
145

패키지 설치

flutter pub add humanize

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Humanize는 원시 데이터를 영어와 프랑스어로 자연스럽고 인간이 읽기 쉬운 텍스트로 변환하는 가벼운 Dart 패키지입니다. 날짜, 숫자, 목록 및 일반 텍스트 포맷팅을 위한 직관적인 도구를 제공하여 UI 콘텐츠가 대화체처럼 매끄럽고 정교하게 느껴지도록 합니다. 봄보일러플레이트 코드 없이 로컬라이즈된 사용자 친화적 출력이 필요한 애플리케이션에 이상적입니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하여 크로스플랫폼 개발에 매우 유연합니다.

사용 사례

  • 읽기 쉬운 문장으로 타임스탬프 형식 지정
  • 숫자를 자연어로 변환하기
  • 'and'를 사용하여 마지막 항목 앞에 쉼표로 구분된 목록 만들기
  • 영어 및 프랑스어 사용자를 위한 UI 텍스트 현지화
  • 앱에서 동적 콘텐츠의 가독성 향상
  • 양식 및 대시보드에서 문자열 생성 간소화

주요 기능

  • 영어 및 프랑스어 지역화를 지원합니다
  • 날짜, 숫자 및 목록을 위한 도우미
  • 직관적인 메서드를 갖춘 최소한의 API
  • 크로스 플랫폼 호환성
  • 경량이며 종속성 없음
  • Flutter pub add를 통한 간편한 통합

적합한 대상

  • 영어 및 프랑스어 사용자를 대상으로 하는 앱
  • 깨끗하고 읽기 쉬운 UI 문자열을 찾는 개발자
  • 무거운 라이브러리 없이 간단한 텍스트 형식 지정이 필요한 프로젝트
  • 현지화와 사용자 경험을 우선시하는 팀
  • 동적 콘텐츠를 표시하는 Flutter 앱
  • 최소한의 설정을 원하는 프론트엔드 개발자

고려 사항

  • 영어 및 프랑스어만 가능
  • 다른 로케일에 대한 지원 없음
  • 복수형과 같은 경계 사례를 수동으로 처리해야 합니다
  • 복잡한 국제화 요구 사항에 적합하지 않습니다
  • 일관된 입력 형식에 의존합니다
  • 비표준 사용 사례를 위한 추가 로직이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Humanize

pub.dev Star on Github Awesome Flutter Flutter Samples License: MIT

Humanize

Humanize for Dart & Flutter 👋

Humanize is a compact toolkit that makes UI strings feel natural. It bridges raw data and human-friendly phrasing with helpers for dates, numbers, lists, and text in English and French.

Table of Contents

Overview

Humanize focuses on pragmatic, readable output for UI strings. It packages natural phrases (e.g., “3 minutes ago”, “tomorrow”) and formatting helpers under a consistent API with light-touch locale support.

Feature Highlights

  • Relative time and calendar-friendly deltas via naturaltime, naturaldelta, naturalday
  • Flexible formatting for DateTime (ISO, RFC 2822, HTTP, timestamps, locale-aware)
  • Humanized lists and text helpers: naturalJoin, oxfordComma, capfirst, titlecase, truncate*
  • Number utilities with locale presets: intcomma, intword, ordinal, apNumber
  • File size display with filesizeformat
  • Calendar math helpers: addCalendarMonths, addCalendarYears
  • Lightweight i18n facade through HumanizeI18n

Getting Started

Installation

dependencies:
  humanize: latest_version
import 'package:humanize/humanize.dart';

Quick Start

print(naturaltime(DateTime.now().subtract(Duration(minutes: 3)), locale: 'en')); // 3 minutes ago
print(naturaldelta(Duration(hours: 2), locale: 'fr'));                            // 2 heures

final ref = DateTime(2007, 2, 17, 12);
print(naturalday(DateTime(2007, 2, 16), now: ref, locale: 'en', format: 'dd MMMM yyyy')); // yesterday

print(naturalJoin(['a','b','c'], locale: 'fr')); // a, b et c
print(oxfordComma(['a','b','c'], locale: 'en')); // a, b, and c

print(intcomma(4500.2));            // 4,500.2
print(intcomma(1234567, sep: ' ')); // 1 234 567
print(intword(1200000, locale: 'fr')); // 1,2 millions
print(filesizeformat(1536));        // 1.5 KB

Usage Guide

Dates & Times
final now = DateTime(2007, 2, 17, 16, 30, 0);
print(naturaltime(now.add(Duration(days: 9)), now: now)); // in 1 week, 2 days
print(naturaltime(now.subtract(Duration(days: 1, hours: 2)), now: now, locale: 'fr')); // il y a un jour, 2 heures

final dt = DateTime(2017,4,20,11,32);
print(dt.toISO());      // 2017-04-20T11:32:00.000-04:00
print(dt.toRFC2822());  // Thu, 20 Apr 2017 11:32:00 -0400
print(dt.toHTTP());     // Thu, 20 Apr 2017 15:32:00 GMT
print(dt.asLocale('fr').toHTTP()); // jeu., 20 avr. 2017 15:32:00 GMT (display)

// Locale formats
print(dt.toLocaleString());                                 // e.g., 4/20/2017
print(dt.toLocaleString(HumanDateFormat.DATETIME_FULL));    // April 20, 2017...
print(dt.asLocale('fr').toLocaleString(HumanDateFormat.DATETIME_FULL)); // 20 avril 2017...
Numbers
print(intcomma(4500));    // 4,500
print(intword(1500000, short: true)); // 1.5 M
print(ordinal(1, locale: 'fr')); // 1er
print(apNumber(5, locale: 'fr')); // cinq
Lists, Text & Filesize
print(naturalJoin(['a','b','c'], locale: 'fr')); // a, b et c
print(oxfordComma(['a','b','c']));               // a, b, and c
print(capfirst('hello'));                        // Hello
print(filesizeformat(1536));                     // 1.5 KB
Calendar Math
final d = DateTime(2017, 2, 13);
print(d.addCalendarMonths(1).toISODate());    // 2017-03-13
print(d.add(Duration(days: 30)).toISODate()); // 2017-03-15
i18n Facade
final hFr = HumanizeI18n('fr');
print(hFr.naturalTime(DateTime.now().subtract(Duration(minutes: 3))));
print(hFr.intComma(1234567)); // 1 234 567

Examples & Tests

Examples in example/: basic_usage.dart, i18n_facade.dart, intcomma_examples.dart, naturaltime_examples.dart, naturalday_examples.dart, ordinal_examples.dart, formatting_examples.dart, math_examples.dart

Run tests:

dart test

Notes & Limitations

  • Built-in locales: en, fr. PRs welcome to extend.
  • For strict formatting (currencies, complex calendars), combine with package:intl and use Humanize for human-friendly phrasing.
  • Localized RFC/HTTP outputs are intended for display only (not protocol-compliant).

Resources

  • License: see LICENSE
  • Repo: https://github.com/jeanluc243/humanize
  • Issues: https://github.com/jeanluc243/humanize/issues

Keywords

  • Dart string formatting
  • Flutter localization helpers
  • humanize dates and numbers
  • Dart natural language utilities
  • human-readable UI text toolkit

Maintainers

Support

If Humanize makes your UI sparkle, feel free to fuel the magic with a donation—anything from a cheeky 🍺 to the legendary MacBook Pro upgrade 💻😂. Tap the link, pick your vibe, and let's keep shipping joy: Buy Me a Coffee.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.