From effbfff1ef7c227fd4d9f3eb0fb6a3ba8d753f4c Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 24 Feb 2016 08:45:53 -0500 Subject: Running save instead of update --- .../go-i18n/i18n/language/codegen/generate.sh | 5 - .../go-i18n/i18n/language/codegen/main.go | 132 ------------ .../go-i18n/i18n/language/codegen/plurals.xml | 230 --------------------- .../go-i18n/i18n/language/codegen/xml.go | 143 ------------- 4 files changed, 510 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/generate.sh delete mode 100644 Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go delete mode 100644 Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/plurals.xml delete mode 100644 Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/xml.go (limited to 'Godeps/_workspace/src/github.com/nicksnyder') diff --git a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/generate.sh b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/generate.sh deleted file mode 100644 index a9fae846a..000000000 --- a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/generate.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -go build && ./codegen -cout ../pluralspec_gen.go -tout ../pluralspec_gen_test.go && \ - gofmt -w=true ../pluralspec_gen.go && \ - gofmt -w=true ../pluralspec_gen_test.go && \ - rm codegen diff --git a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go deleted file mode 100644 index 5d6b6ad4f..000000000 --- a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go +++ /dev/null @@ -1,132 +0,0 @@ -package main - -import ( - "encoding/xml" - "flag" - "fmt" - "io/ioutil" - "os" - "text/template" -) - -var usage = `%[1]s generates Go code to support CLDR plural rules. - -Usage: %[1]s [options] - -Options: - -` - -func main() { - flag.Usage = func() { - fmt.Fprintf(os.Stderr, usage, os.Args[0]) - flag.PrintDefaults() - } - var in, cout, tout string - flag.StringVar(&in, "i", "plurals.xml", "the input XML file containing CLDR plural rules") - flag.StringVar(&cout, "cout", "", "the code output file") - flag.StringVar(&tout, "tout", "", "the test output file") - flag.BoolVar(&verbose, "v", false, "verbose output") - flag.Parse() - - buf, err := ioutil.ReadFile(in) - if err != nil { - fatalf("failed to read file: %s", err) - } - - var data SupplementalData - if err := xml.Unmarshal(buf, &data); err != nil { - fatalf("failed to unmarshal xml: %s", err) - } - - count := 0 - for _, pg := range data.PluralGroups { - count += len(pg.SplitLocales()) - } - infof("parsed %d locales", count) - - if cout != "" { - file := openWritableFile(cout) - if err := codeTemplate.Execute(file, data); err != nil { - fatalf("unable to execute code template because %s", err) - } else { - infof("generated %s", cout) - } - } else { - infof("not generating code file (use -cout)") - } - - if tout != "" { - file := openWritableFile(tout) - if err := testTemplate.Execute(file, data); err != nil { - fatalf("unable to execute test template because %s", err) - } else { - infof("generated %s", tout) - } - } else { - infof("not generating test file (use -tout)") - } -} - -func openWritableFile(name string) *os.File { - file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) - if err != nil { - fatalf("failed to write file %s because %s", name, err) - } - return file -} - -var codeTemplate = template.Must(template.New("spec").Parse(`package language -// This file is generated by i18n/language/codegen/generate.sh - -func init() { -{{range .PluralGroups}} - registerPluralSpec({{printf "%#v" .SplitLocales}}, &PluralSpec{ - Plurals: newPluralSet({{range $i, $e := .PluralRules}}{{if $i}}, {{end}}{{$e.CountTitle}}{{end}}), - PluralFunc: func(ops *operands) Plural { {{range .PluralRules}}{{if .GoCondition}} - // {{.Condition}} - if {{.GoCondition}} { - return {{.CountTitle}} - }{{end}}{{end}} - return Other - }, - }){{end}} -} -`)) - -var testTemplate = template.Must(template.New("spec").Parse(`package language -// This file is generated by i18n/language/codegen/generate.sh - -import "testing" - -{{range .PluralGroups}} -func Test{{.Name}}(t *testing.T) { - var tests []pluralTest - {{range .PluralRules}} - {{if .IntegerExamples}}tests = appendIntegerTests(tests, {{.CountTitle}}, {{printf "%#v" .IntegerExamples}}){{end}} - {{if .DecimalExamples}}tests = appendDecimalTests(tests, {{.CountTitle}}, {{printf "%#v" .DecimalExamples}}){{end}} - {{end}} - locales := {{printf "%#v" .SplitLocales}} - for _, locale := range locales { - runTests(t, locale, tests) - } -} -{{end}} -`)) - -func infof(format string, args ...interface{}) { - fmt.Fprintf(os.Stderr, format+"\n", args...) -} - -var verbose bool - -func verbosef(format string, args ...interface{}) { - if verbose { - infof(format, args...) - } -} - -func fatalf(format string, args ...interface{}) { - infof("fatal: "+format+"\n", args...) - os.Exit(1) -} diff --git a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/plurals.xml b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/plurals.xml deleted file mode 100644 index cdd0b5296..000000000 --- a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/plurals.xml +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - - - - - @integer 0~15, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~2.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - i = 0,1 @integer 0, 1 @decimal 0.0~1.5 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - i = 1 and v = 0 @integer 1 - @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 0,1 or i = 0 and f = 1 @integer 0, 1 @decimal 0.0, 0.1, 1.0, 0.00, 0.01, 1.00, 0.000, 0.001, 1.000, 0.0000, 0.0001, 1.0000 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.2~0.9, 1.1~1.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 0..1 @integer 0, 1 @decimal 0.0, 1.0, 0.00, 1.00, 0.000, 1.000, 0.0000, 1.0000 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 0..1 or n = 11..99 @integer 0, 1, 11~24 @decimal 0.0, 1.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0 - @integer 2~10, 100~106, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 0..2 and n != 2 @integer 0, 1 @decimal 0.0, 1.0, 0.00, 1.00, 0.000, 1.000, 0.0000, 1.0000 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 1 and v = 0 @integer 1 - @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 1 or t != 0 and i = 0,1 @integer 1 @decimal 0.1~1.6 - @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 2.0~3.4, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - t = 0 and i % 10 = 1 and i % 100 != 11 or t != 0 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1~1.6, 10.1, 100.1, 1000.1, … - @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - v = 0 and i % 10 = 1 or f % 10 = 1 @integer 1, 11, 21, 31, 41, 51, 61, 71, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, … - @integer 0, 2~10, 12~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.2~1.0, 1.2~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9 @integer 0~3, 5, 7, 8, 10~13, 15, 17, 18, 20, 21, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.3, 0.5, 0.7, 0.8, 1.0~1.3, 1.5, 1.7, 1.8, 2.0, 2.1, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - @integer 4, 6, 9, 14, 16, 19, 24, 26, 104, 1004, … @decimal 0.4, 0.6, 0.9, 1.4, 1.6, 1.9, 2.4, 2.6, 10.4, 100.4, 1000.4, … - - - - - - n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19 @integer 0, 10~20, 30, 40, 50, 60, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.0, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, … - @integer 2~9, 22~29, 102, 1002, … @decimal 0.2~0.9, 1.2~1.9, 10.2, 100.2, 1000.2, … - - - n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000 - i = 0,1 and n != 0 @integer 1 @decimal 0.1~1.6 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000 - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000 - @integer 0, 3~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04 - n = 2..10 @integer 2~10 @decimal 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00, 8.00 - @integer 11~26, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~1.9, 2.1~2.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - i = 1 and v = 0 @integer 1 - v != 0 or n = 0 or n != 1 and n % 100 = 1..19 @integer 0, 2~16, 101, 1001, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - @integer 20~35, 100, 1000, 10000, 100000, 1000000, … - - - v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, … - v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, … - @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.5~1.0, 1.5~2.0, 2.5~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - n = 1,11 @integer 1, 11 @decimal 1.0, 11.0, 1.00, 11.00, 1.000, 11.000, 1.0000 - n = 2,12 @integer 2, 12 @decimal 2.0, 12.0, 2.00, 12.00, 2.000, 12.000, 2.0000 - n = 3..10,13..19 @integer 3~10, 13~19 @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 3.00 - @integer 0, 20~34, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - v = 0 and i % 100 = 1 @integer 1, 101, 201, 301, 401, 501, 601, 701, 1001, … - v = 0 and i % 100 = 2 @integer 2, 102, 202, 302, 402, 502, 602, 702, 1002, … - v = 0 and i % 100 = 3..4 or v != 0 @integer 3, 4, 103, 104, 203, 204, 303, 304, 403, 404, 503, 504, 603, 604, 703, 704, 1003, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … - - - v = 0 and i % 100 = 1 or f % 100 = 1 @integer 1, 101, 201, 301, 401, 501, 601, 701, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, … - v = 0 and i % 100 = 2 or f % 100 = 2 @integer 2, 102, 202, 302, 402, 502, 602, 702, 1002, … @decimal 0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 10.2, 100.2, 1000.2, … - v = 0 and i % 100 = 3..4 or f % 100 = 3..4 @integer 3, 4, 103, 104, 203, 204, 303, 304, 403, 404, 503, 504, 603, 604, 703, 704, 1003, … @decimal 0.3, 0.4, 1.3, 1.4, 2.3, 2.4, 3.3, 3.4, 4.3, 4.4, 5.3, 5.4, 6.3, 6.4, 7.3, 7.4, 10.3, 100.3, 1000.3, … - @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.5~1.0, 1.5~2.0, 2.5~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - i = 1 and v = 0 @integer 1 - i = 2 and v = 0 @integer 2 - v = 0 and n != 0..10 and n % 10 = 0 @integer 20, 30, 40, 50, 60, 70, 80, 90, 100, 1000, 10000, 100000, 1000000, … - @integer 0, 3~17, 101, 1001, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - i = 1 and v = 0 @integer 1 - i = 2..4 and v = 0 @integer 2~4 - v != 0 @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … - - - i = 1 and v = 0 @integer 1 - v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … - v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … - @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n % 10 = 1 and n % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, … - n % 10 = 2..4 and n % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 2.0, 3.0, 4.0, 22.0, 23.0, 24.0, 32.0, 33.0, 102.0, 1002.0, … - n % 10 = 0 or n % 10 = 5..9 or n % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, … - - - n % 10 = 1 and n % 100 != 11..19 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, … - n % 10 = 2..9 and n % 100 != 11..19 @integer 2~9, 22~29, 102, 1002, … @decimal 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 22.0, 102.0, 1002.0, … - f != 0 @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, … - @integer 0, 10~20, 30, 40, 50, 60, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - n = 0 or n % 100 = 2..10 @integer 0, 2~10, 102~107, 1002, … @decimal 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 102.0, 1002.0, … - n % 100 = 11..19 @integer 11~19, 111~117, 1011, … @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, … - @integer 20~35, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - v = 0 and i % 10 = 1 and i % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … - v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … - v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … - @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - - - - n % 10 = 1 and n % 100 != 11,71,91 @integer 1, 21, 31, 41, 51, 61, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 81.0, 101.0, 1001.0, … - n % 10 = 2 and n % 100 != 12,72,92 @integer 2, 22, 32, 42, 52, 62, 82, 102, 1002, … @decimal 2.0, 22.0, 32.0, 42.0, 52.0, 62.0, 82.0, 102.0, 1002.0, … - n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99 @integer 3, 4, 9, 23, 24, 29, 33, 34, 39, 43, 44, 49, 103, 1003, … @decimal 3.0, 4.0, 9.0, 23.0, 24.0, 29.0, 33.0, 34.0, 103.0, 1003.0, … - n != 0 and n % 1000000 = 0 @integer 1000000, … @decimal 1000000.0, 1000000.00, 1000000.000, … - @integer 0, 5~8, 10~20, 100, 1000, 10000, 100000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, … - - - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000 - n = 3..6 @integer 3~6 @decimal 3.0, 4.0, 5.0, 6.0, 3.00, 4.00, 5.00, 6.00, 3.000, 4.000, 5.000, 6.000, 3.0000, 4.0000, 5.0000, 6.0000 - n = 7..10 @integer 7~10 @decimal 7.0, 8.0, 9.0, 10.0, 7.00, 8.00, 9.00, 10.00, 7.000, 8.000, 9.000, 10.000, 7.0000, 8.0000, 9.0000, 10.0000 - @integer 0, 11~25, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - v = 0 and i % 10 = 1 @integer 1, 11, 21, 31, 41, 51, 61, 71, 101, 1001, … - v = 0 and i % 10 = 2 @integer 2, 12, 22, 32, 42, 52, 62, 72, 102, 1002, … - v = 0 and i % 100 = 0,20,40,60,80 @integer 0, 20, 40, 60, 80, 100, 120, 140, 1000, 10000, 100000, 1000000, … - v != 0 @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - @integer 3~10, 13~19, 23, 103, 1003, … - - - - - - n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000 - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000 - n % 100 = 3..10 @integer 3~10, 103~110, 1003, … @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, … - n % 100 = 11..99 @integer 11~26, 111, 1011, … @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, … - @integer 100~102, 200~202, 300~302, 400~402, 500~502, 600, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000 - n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000 - n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000 - n = 3 @integer 3 @decimal 3.0, 3.00, 3.000, 3.0000 - n = 6 @integer 6 @decimal 6.0, 6.00, 6.000, 6.0000 - @integer 4, 5, 7~20, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … - - - diff --git a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/xml.go b/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/xml.go deleted file mode 100644 index 9d39053c2..000000000 --- a/Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/codegen/xml.go +++ /dev/null @@ -1,143 +0,0 @@ -package main - -import ( - "encoding/xml" - "fmt" - "regexp" - "strings" -) - -// SupplementalData is the top level struct of plural.xml -type SupplementalData struct { - XMLName xml.Name `xml:"supplementalData"` - PluralGroups []PluralGroup `xml:"plurals>pluralRules"` -} - -// PluralGroup is a group of locales with the same plural rules. -type PluralGroup struct { - Locales string `xml:"locales,attr"` - PluralRules []PluralRule `xml:"pluralRule"` -} - -// Name returns a unique name for this plural group. -func (pg *PluralGroup) Name() string { - n := strings.Title(pg.Locales) - return strings.Replace(n, " ", "", -1) -} - -// SplitLocales returns all the locales in the PluralGroup as a slice. -func (pg *PluralGroup) SplitLocales() []string { - return strings.Split(pg.Locales, " ") -} - -// PluralRule is the rule for a single plural form. -type PluralRule struct { - Count string `xml:"count,attr"` - Rule string `xml:",innerxml"` -} - -// CountTitle returns the title case of the PluralRule's count. -func (pr *PluralRule) CountTitle() string { - return strings.Title(pr.Count) -} - -// Condition returns the condition where the PluralRule applies. -func (pr *PluralRule) Condition() string { - i := strings.Index(pr.Rule, "@") - return pr.Rule[:i] -} - -// Examples returns the integer and decimal exmaples for the PLuralRule. -func (pr *PluralRule) Examples() (integer []string, decimal []string) { - ex := strings.Replace(pr.Rule, ", …", "", -1) - ddelim := "@decimal" - if i := strings.Index(ex, ddelim); i > 0 { - dex := strings.TrimSpace(ex[i+len(ddelim):]) - decimal = strings.Split(dex, ", ") - ex = ex[:i] - } - idelim := "@integer" - if i := strings.Index(ex, idelim); i > 0 { - iex := strings.TrimSpace(ex[i+len(idelim):]) - integer = strings.Split(iex, ", ") - } - return integer, decimal -} - -// IntegerExamples returns the integer exmaples for the PLuralRule. -func (pr *PluralRule) IntegerExamples() []string { - integer, _ := pr.Examples() - return integer -} - -// DecimalExamples returns the decimal exmaples for the PLuralRule. -func (pr *PluralRule) DecimalExamples() []string { - _, decimal := pr.Examples() - return decimal -} - -var relationRegexp = regexp.MustCompile("([niftvw])(?: % ([0-9]+))? (!=|=)(.*)") - -// GoCondition converts the XML condition to valid Go code. -func (pr *PluralRule) GoCondition() string { - var ors []string - for _, and := range strings.Split(pr.Condition(), "or") { - var ands []string - for _, relation := range strings.Split(and, "and") { - parts := relationRegexp.FindStringSubmatch(relation) - if parts == nil { - continue - } - lvar, lmod, op, rhs := strings.Title(parts[1]), parts[2], parts[3], strings.TrimSpace(parts[4]) - if op == "=" { - op = "==" - } - lvar = "ops." + lvar - var rhor []string - var rany []string - for _, rh := range strings.Split(rhs, ",") { - if parts := strings.Split(rh, ".."); len(parts) == 2 { - from, to := parts[0], parts[1] - if lvar == "ops.N" { - if lmod != "" { - rhor = append(rhor, fmt.Sprintf("ops.NmodInRange(%s, %s, %s)", lmod, from, to)) - } else { - rhor = append(rhor, fmt.Sprintf("ops.NinRange(%s, %s)", from, to)) - } - } else if lmod != "" { - rhor = append(rhor, fmt.Sprintf("intInRange(%s %% %s, %s, %s)", lvar, lmod, from, to)) - } else { - rhor = append(rhor, fmt.Sprintf("intInRange(%s, %s, %s)", lvar, from, to)) - } - } else { - rany = append(rany, rh) - } - } - - if len(rany) > 0 { - rh := strings.Join(rany, ",") - if lvar == "ops.N" { - if lmod != "" { - rhor = append(rhor, fmt.Sprintf("ops.NmodEqualsAny(%s, %s)", lmod, rh)) - } else { - rhor = append(rhor, fmt.Sprintf("ops.NequalsAny(%s)", rh)) - } - } else if lmod != "" { - rhor = append(rhor, fmt.Sprintf("intEqualsAny(%s %% %s, %s)", lvar, lmod, rh)) - } else { - rhor = append(rhor, fmt.Sprintf("intEqualsAny(%s, %s)", lvar, rh)) - } - } - r := strings.Join(rhor, " || ") - if len(rhor) > 1 { - r = "(" + r + ")" - } - if op == "!=" { - r = "!" + r - } - ands = append(ands, r) - } - ors = append(ors, strings.Join(ands, " && ")) - } - return strings.Join(ors, " ||\n") -} -- cgit v1.2.3-1-g7c22