8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
24 currencies []string // idx = enum of currency code
25 currencyNegativePrefix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
30 daysAbbreviated []string
34 periodsAbbreviated []string
35 periodsNarrow []string
38 erasAbbreviated []string
41 timezones map[string]string
44 // New returns a new instance of translator for the 'ja_JP' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{6},
49 pluralsOrdinal: []locales.PluralRule{6},
50 pluralsRange: []locales.PluralRule{6},
58 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59 currencyNegativePrefix: "(",
60 currencyNegativeSuffix: ")",
61 monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
62 monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
63 monthsWide: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
64 daysAbbreviated: []string{"日", "月", "火", "水", "木", "金", "土"},
65 daysNarrow: []string{"日", "月", "火", "水", "木", "金", "土"},
66 daysShort: []string{"日", "月", "火", "水", "木", "金", "土"},
67 daysWide: []string{"日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"},
68 periodsAbbreviated: []string{"午前", "午後"},
69 periodsNarrow: []string{"午前", "午後"},
70 periodsWide: []string{"午前", "午後"},
71 erasAbbreviated: []string{"紀元前", "西暦"},
72 erasNarrow: []string{"BC", "AD"},
73 erasWide: []string{"紀元前", "西暦"},
74 timezones: map[string]string{"ADT": "大西洋夏時間", "COST": "コロンビア夏時間", "HNPM": "サンピエール・ミクロン標準時", "WIB": "インドネシア西部時間", "HEPM": "サンピエール・ミクロン夏時間", "NZST": "ニュージーランド標準時", "LHST": "ロードハウ標準時", "HNNOMX": "メキシコ北西部標準時", "CLT": "チリ標準時", "GYT": "ガイアナ時間", "ACWST": "オーストラリア中西部標準時", "HNOG": "グリーンランド西部標準時", "EDT": "アメリカ東部夏時間", "HECU": "キューバ夏時間", "BT": "ブータン時間", "CDT": "アメリカ中部夏時間", "WAST": "西アフリカ夏時間", "HNT": "ニューファンドランド標準時", "WEZ": "西ヨーロッパ標準時", "NZDT": "ニュージーランド夏時間", "VET": "ベネズエラ時間", "WITA": "インドネシア中部時間", "OESZ": "東ヨーロッパ夏時間", "AST": "大西洋標準時", "WESZ": "西ヨーロッパ夏時間", "CHADT": "チャタム夏時間", "WIT": "インドネシア東部時間", "HADT": "ハワイ・アリューシャン夏時間", "MESZ": "中央ヨーロッパ夏時間", "MST": "アメリカ山地標準時", "HEOG": "グリーンランド西部夏時間", "HKST": "香港夏時間", "SAST": "南アフリカ標準時", "BOT": "ボリビア時間", "CST": "アメリカ中部標準時", "MDT": "アメリカ山地夏時間", "WARST": "西部アルゼンチン夏時間", "AEDT": "オーストラリア東部夏時間", "HKT": "香港標準時", "HEPMX": "メキシコ太平洋夏時間", "UYST": "ウルグアイ夏時間", "TMT": "トルクメニスタン標準時", "WART": "西部アルゼンチン標準時", "WAT": "西アフリカ標準時", "CAT": "中央アフリカ時間", "SRT": "スリナム時間", "AWST": "オーストラリア西部標準時", "TMST": "トルクメニスタン夏時間", "CLST": "チリ夏時間", "COT": "コロンビア標準時", "AKST": "アラスカ標準時", "SGT": "シンガポール標準時", "OEZ": "東ヨーロッパ標準時", "AEST": "オーストラリア東部標準時", "EAT": "東アフリカ時間", "ACST": "オーストラリア中部標準時", "ACDT": "オーストラリア中部夏時間", "MYT": "マレーシア時間", "HENOMX": "メキシコ北西部夏時間", "HNEG": "グリーンランド東部標準時", "EST": "アメリカ東部標準時", "ChST": "チャモロ時間", "HNPMX": "メキシコ太平洋標準時", "GMT": "グリニッジ標準時", "HNCU": "キューバ標準時", "PDT": "アメリカ太平洋夏時間", "HAST": "ハワイ・アリューシャン標準時", "GFT": "仏領ギアナ時間", "AKDT": "アラスカ夏時間", "ACWDT": "オーストラリア中西部夏時間", "JDT": "日本夏時間", "ART": "アルゼンチン標準時", "PST": "アメリカ太平洋標準時", "AWDT": "オーストラリア西部夏時間", "HAT": "ニューファンドランド夏時間", "CHAST": "チャタム標準時", "UYT": "ウルグアイ標準時", "JST": "日本標準時", "∅∅∅": "アゾレス夏時間", "IST": "インド標準時", "ARST": "アルゼンチン夏時間", "HEEG": "グリーンランド東部夏時間", "MEZ": "中央ヨーロッパ標準時", "LHDT": "ロードハウ夏時間", "ECT": "エクアドル時間"},
78 // Locale returns the current translators string locale
79 func (ja *ja_JP) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'ja_JP'
84 func (ja *ja_JP) PluralsCardinal() []locales.PluralRule {
85 return ja.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'ja_JP'
89 func (ja *ja_JP) PluralsOrdinal() []locales.PluralRule {
90 return ja.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'ja_JP'
94 func (ja *ja_JP) PluralsRange() []locales.PluralRule {
95 return ja.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ja_JP'
99 func (ja *ja_JP) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleOther
103 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ja_JP'
104 func (ja *ja_JP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
105 return locales.PluralRuleOther
108 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ja_JP'
109 func (ja *ja_JP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
110 return locales.PluralRuleOther
113 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
114 func (ja *ja_JP) MonthAbbreviated(month time.Month) string {
115 return ja.monthsAbbreviated[month]
118 // MonthsAbbreviated returns the locales abbreviated months
119 func (ja *ja_JP) MonthsAbbreviated() []string {
120 return ja.monthsAbbreviated[1:]
123 // MonthNarrow returns the locales narrow month given the 'month' provided
124 func (ja *ja_JP) MonthNarrow(month time.Month) string {
125 return ja.monthsNarrow[month]
128 // MonthsNarrow returns the locales narrow months
129 func (ja *ja_JP) MonthsNarrow() []string {
130 return ja.monthsNarrow[1:]
133 // MonthWide returns the locales wide month given the 'month' provided
134 func (ja *ja_JP) MonthWide(month time.Month) string {
135 return ja.monthsWide[month]
138 // MonthsWide returns the locales wide months
139 func (ja *ja_JP) MonthsWide() []string {
140 return ja.monthsWide[1:]
143 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
144 func (ja *ja_JP) WeekdayAbbreviated(weekday time.Weekday) string {
145 return ja.daysAbbreviated[weekday]
148 // WeekdaysAbbreviated returns the locales abbreviated weekdays
149 func (ja *ja_JP) WeekdaysAbbreviated() []string {
150 return ja.daysAbbreviated
153 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
154 func (ja *ja_JP) WeekdayNarrow(weekday time.Weekday) string {
155 return ja.daysNarrow[weekday]
158 // WeekdaysNarrow returns the locales narrow weekdays
159 func (ja *ja_JP) WeekdaysNarrow() []string {
163 // WeekdayShort returns the locales short weekday given the 'weekday' provided
164 func (ja *ja_JP) WeekdayShort(weekday time.Weekday) string {
165 return ja.daysShort[weekday]
168 // WeekdaysShort returns the locales short weekdays
169 func (ja *ja_JP) WeekdaysShort() []string {
173 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
174 func (ja *ja_JP) WeekdayWide(weekday time.Weekday) string {
175 return ja.daysWide[weekday]
178 // WeekdaysWide returns the locales wide weekdays
179 func (ja *ja_JP) WeekdaysWide() []string {
183 // Decimal returns the decimal point of number
184 func (ja *ja_JP) Decimal() string {
188 // Group returns the group of number
189 func (ja *ja_JP) Group() string {
193 // Group returns the minus sign of number
194 func (ja *ja_JP) Minus() string {
198 // FmtNumber returns 'num' with digits/precision of 'v' for 'ja_JP' and handles both Whole and Real numbers based on 'v'
199 func (ja *ja_JP) FmtNumber(num float64, v uint64) string {
201 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
205 b := make([]byte, 0, l)
207 for i := len(s) - 1; i >= 0; i-- {
210 b = append(b, ja.decimal[0])
217 b = append(b, ja.group[0])
228 b = append(b, ja.minus[0])
232 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
233 b[i], b[j] = b[j], b[i]
239 // FmtPercent returns 'num' with digits/precision of 'v' for 'ja_JP' and handles both Whole and Real numbers based on 'v'
240 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
241 func (ja *ja_JP) FmtPercent(num float64, v uint64) string {
242 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
244 b := make([]byte, 0, l)
246 for i := len(s) - 1; i >= 0; i-- {
249 b = append(b, ja.decimal[0])
257 b = append(b, ja.minus[0])
261 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
262 b[i], b[j] = b[j], b[i]
265 b = append(b, ja.percent...)
270 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ja_JP'
271 func (ja *ja_JP) FmtCurrency(num float64, v uint64, currency currency.Type) string {
273 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274 symbol := ja.currencies[currency]
275 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
278 b := make([]byte, 0, l)
280 for i := len(s) - 1; i >= 0; i-- {
283 b = append(b, ja.decimal[0])
290 b = append(b, ja.group[0])
300 for j := len(symbol) - 1; j >= 0; j-- {
301 b = append(b, symbol[j])
305 b = append(b, ja.minus[0])
309 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
310 b[i], b[j] = b[j], b[i]
316 b = append(b, ja.decimal...)
319 for i := 0; i < 2-int(v); i++ {
327 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ja_JP'
328 // in accounting notation.
329 func (ja *ja_JP) FmtAccounting(num float64, v uint64, currency currency.Type) string {
331 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
332 symbol := ja.currencies[currency]
333 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
336 b := make([]byte, 0, l)
338 for i := len(s) - 1; i >= 0; i-- {
341 b = append(b, ja.decimal[0])
348 b = append(b, ja.group[0])
360 for j := len(symbol) - 1; j >= 0; j-- {
361 b = append(b, symbol[j])
364 b = append(b, ja.currencyNegativePrefix[0])
368 for j := len(symbol) - 1; j >= 0; j-- {
369 b = append(b, symbol[j])
375 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
376 b[i], b[j] = b[j], b[i]
382 b = append(b, ja.decimal...)
385 for i := 0; i < 2-int(v); i++ {
391 b = append(b, ja.currencyNegativeSuffix...)
397 // FmtDateShort returns the short date representation of 't' for 'ja_JP'
398 func (ja *ja_JP) FmtDateShort(t time.Time) string {
400 b := make([]byte, 0, 32)
403 b = strconv.AppendInt(b, int64(t.Year()), 10)
405 b = strconv.AppendInt(b, int64(-t.Year()), 10)
408 b = append(b, []byte{0x2f}...)
414 b = strconv.AppendInt(b, int64(t.Month()), 10)
416 b = append(b, []byte{0x2f}...)
422 b = strconv.AppendInt(b, int64(t.Day()), 10)
427 // FmtDateMedium returns the medium date representation of 't' for 'ja_JP'
428 func (ja *ja_JP) FmtDateMedium(t time.Time) string {
430 b := make([]byte, 0, 32)
433 b = strconv.AppendInt(b, int64(t.Year()), 10)
435 b = strconv.AppendInt(b, int64(-t.Year()), 10)
438 b = append(b, []byte{0x2f}...)
444 b = strconv.AppendInt(b, int64(t.Month()), 10)
446 b = append(b, []byte{0x2f}...)
452 b = strconv.AppendInt(b, int64(t.Day()), 10)
457 // FmtDateLong returns the long date representation of 't' for 'ja_JP'
458 func (ja *ja_JP) FmtDateLong(t time.Time) string {
460 b := make([]byte, 0, 32)
463 b = strconv.AppendInt(b, int64(t.Year()), 10)
465 b = strconv.AppendInt(b, int64(-t.Year()), 10)
468 b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
469 b = strconv.AppendInt(b, int64(t.Month()), 10)
470 b = append(b, []byte{0xe6, 0x9c, 0x88}...)
471 b = strconv.AppendInt(b, int64(t.Day()), 10)
472 b = append(b, []byte{0xe6, 0x97, 0xa5}...)
477 // FmtDateFull returns the full date representation of 't' for 'ja_JP'
478 func (ja *ja_JP) FmtDateFull(t time.Time) string {
480 b := make([]byte, 0, 32)
483 b = strconv.AppendInt(b, int64(t.Year()), 10)
485 b = strconv.AppendInt(b, int64(-t.Year()), 10)
488 b = append(b, []byte{0xe5, 0xb9, 0xb4}...)
489 b = strconv.AppendInt(b, int64(t.Month()), 10)
490 b = append(b, []byte{0xe6, 0x9c, 0x88}...)
491 b = strconv.AppendInt(b, int64(t.Day()), 10)
492 b = append(b, []byte{0xe6, 0x97, 0xa5}...)
493 b = append(b, ja.daysWide[t.Weekday()]...)
498 // FmtTimeShort returns the short time representation of 't' for 'ja_JP'
499 func (ja *ja_JP) FmtTimeShort(t time.Time) string {
501 b := make([]byte, 0, 32)
503 b = strconv.AppendInt(b, int64(t.Hour()), 10)
504 b = append(b, ja.timeSeparator...)
510 b = strconv.AppendInt(b, int64(t.Minute()), 10)
515 // FmtTimeMedium returns the medium time representation of 't' for 'ja_JP'
516 func (ja *ja_JP) FmtTimeMedium(t time.Time) string {
518 b := make([]byte, 0, 32)
520 b = strconv.AppendInt(b, int64(t.Hour()), 10)
521 b = append(b, ja.timeSeparator...)
527 b = strconv.AppendInt(b, int64(t.Minute()), 10)
528 b = append(b, ja.timeSeparator...)
534 b = strconv.AppendInt(b, int64(t.Second()), 10)
539 // FmtTimeLong returns the long time representation of 't' for 'ja_JP'
540 func (ja *ja_JP) FmtTimeLong(t time.Time) string {
542 b := make([]byte, 0, 32)
544 b = strconv.AppendInt(b, int64(t.Hour()), 10)
545 b = append(b, ja.timeSeparator...)
551 b = strconv.AppendInt(b, int64(t.Minute()), 10)
552 b = append(b, ja.timeSeparator...)
558 b = strconv.AppendInt(b, int64(t.Second()), 10)
559 b = append(b, []byte{0x20}...)
567 // FmtTimeFull returns the full time representation of 't' for 'ja_JP'
568 func (ja *ja_JP) FmtTimeFull(t time.Time) string {
570 b := make([]byte, 0, 32)
572 b = strconv.AppendInt(b, int64(t.Hour()), 10)
573 b = append(b, []byte{0xe6, 0x99, 0x82}...)
579 b = strconv.AppendInt(b, int64(t.Minute()), 10)
580 b = append(b, []byte{0xe5, 0x88, 0x86}...)
586 b = strconv.AppendInt(b, int64(t.Second()), 10)
587 b = append(b, []byte{0xe7, 0xa7, 0x92, 0x20}...)
591 if btz, ok := ja.timezones[tz]; ok {
592 b = append(b, btz...)