Skip to content

A pure Go implementation of the FormatJS parsers.

License

keelet/icuparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

icuparser

Go parsers for ICU MessageFormat strings and formatting skeletons.

Installation

go get github.com/keelet/icuparser

Packages

skeleton

Parse ICU date/time and number formatting skeletons into structured format options.

import "github.com/keelet/icuparser/skeleton"

// Parse date/time skeleton
opts, err := skeleton.ParseDateTimeSkeleton("yyyy.MM.dd HH:mm:ss")

// Parse number skeleton
tokens, err := skeleton.ParseNumberSkeletonFromString("percent .##")
opts, err := skeleton.ParseNumberSkeleton(tokens)

messageformat

Parse ICU MessageFormat strings into an AST.

import "github.com/keelet/icuparser/messageformat"

// Parse a simple message
ast, err := messageformat.Parse("Hello {name}!", nil)

// Parse complex messages with plural/select
ast, err = messageformat.Parse("{count, plural, one {# item} other {# items}}", nil)

Testing

go test ./...

License

icuparser is distributed under the terms of the Apache-2.0 license.

This repository contains Go ports of the following FormatJS packages:

These packages are distributed under the terms of the MIT license.

About

A pure Go implementation of the FormatJS parsers.

Topics

Resources

License

Stars

Watchers

Forks

Languages