Browse Source

Add timezone logic + locale specific info

joeybloggs 9 years ago
parent
commit
4d5203f4ff
100 changed files with 452 additions and 219 deletions
  1. 1 0
      af/af.go
  2. 1 0
      af_NA/af_NA.go
  3. 1 0
      af_ZA/af_ZA.go
  4. 1 0
      agq/agq.go
  5. 1 0
      agq_CM/agq_CM.go
  6. 1 0
      ak/ak.go
  7. 1 0
      ak_GH/ak_GH.go
  8. 1 0
      am/am.go
  9. 1 0
      am_ET/am_ET.go
  10. 1 0
      ar/ar.go
  11. 1 0
      ar_001/ar_001.go
  12. 1 0
      ar_AE/ar_AE.go
  13. 1 0
      ar_BH/ar_BH.go
  14. 1 0
      ar_DJ/ar_DJ.go
  15. 1 0
      ar_DZ/ar_DZ.go
  16. 1 0
      ar_EG/ar_EG.go
  17. 1 0
      ar_EH/ar_EH.go
  18. 1 0
      ar_ER/ar_ER.go
  19. 1 0
      ar_IL/ar_IL.go
  20. 1 0
      ar_IQ/ar_IQ.go
  21. 1 0
      ar_JO/ar_JO.go
  22. 1 0
      ar_KM/ar_KM.go
  23. 1 0
      ar_KW/ar_KW.go
  24. 1 0
      ar_LB/ar_LB.go
  25. 1 0
      ar_LY/ar_LY.go
  26. 1 0
      ar_MA/ar_MA.go
  27. 1 0
      ar_MR/ar_MR.go
  28. 1 0
      ar_OM/ar_OM.go
  29. 1 0
      ar_PS/ar_PS.go
  30. 1 0
      ar_QA/ar_QA.go
  31. 1 0
      ar_SA/ar_SA.go
  32. 1 0
      ar_SD/ar_SD.go
  33. 1 0
      ar_SO/ar_SO.go
  34. 1 0
      ar_SS/ar_SS.go
  35. 1 0
      ar_SY/ar_SY.go
  36. 1 0
      ar_TD/ar_TD.go
  37. 1 0
      ar_TN/ar_TN.go
  38. 1 0
      ar_YE/ar_YE.go
  39. 1 0
      as/as.go
  40. 1 0
      as_IN/as_IN.go
  41. 1 0
      asa/asa.go
  42. 1 0
      asa_TZ/asa_TZ.go
  43. 1 0
      ast/ast.go
  44. 1 0
      ast_ES/ast_ES.go
  45. 1 0
      az/az.go
  46. 1 0
      az_Cyrl/az_Cyrl.go
  47. 1 0
      az_Cyrl_AZ/az_Cyrl_AZ.go
  48. 1 0
      az_Latn/az_Latn.go
  49. 1 0
      az_Latn_AZ/az_Latn_AZ.go
  50. 1 0
      bas/bas.go
  51. 1 0
      bas_CM/bas_CM.go
  52. 1 0
      be/be.go
  53. 1 0
      be_BY/be_BY.go
  54. 1 0
      bem/bem.go
  55. 1 0
      bem_ZM/bem_ZM.go
  56. 1 0
      bez/bez.go
  57. 1 0
      bez_TZ/bez_TZ.go
  58. 1 0
      bg/bg.go
  59. 1 0
      bg_BG/bg_BG.go
  60. 1 0
      bm/bm.go
  61. 1 0
      bm_ML/bm_ML.go
  62. 1 0
      bn/bn.go
  63. 1 0
      bn_BD/bn_BD.go
  64. 1 0
      bn_IN/bn_IN.go
  65. 1 0
      bo/bo.go
  66. 1 0
      bo_CN/bo_CN.go
  67. 1 0
      bo_IN/bo_IN.go
  68. 1 0
      br/br.go
  69. 1 0
      br_FR/br_FR.go
  70. 1 0
      brx/brx.go
  71. 1 0
      brx_IN/brx_IN.go
  72. 1 0
      bs/bs.go
  73. 1 0
      bs_Cyrl/bs_Cyrl.go
  74. 1 0
      bs_Cyrl_BA/bs_Cyrl_BA.go
  75. 1 0
      bs_Latn/bs_Latn.go
  76. 1 0
      bs_Latn_BA/bs_Latn_BA.go
  77. 1 0
      ca/ca.go
  78. 1 0
      ca_AD/ca_AD.go
  79. 1 0
      ca_ES/ca_ES.go
  80. 1 0
      ca_ES_VALENCIA/ca_ES_VALENCIA.go
  81. 1 0
      ca_FR/ca_FR.go
  82. 1 0
      ca_IT/ca_IT.go
  83. 1 0
      ce/ce.go
  84. 1 0
      ce_RU/ce_RU.go
  85. 1 0
      cgg/cgg.go
  86. 1 0
      cgg_UG/cgg_UG.go
  87. 1 0
      chr/chr.go
  88. 1 0
      chr_US/chr_US.go
  89. 1 0
      ckb/ckb.go
  90. 1 0
      ckb_IQ/ckb_IQ.go
  91. 1 0
      ckb_IR/ckb_IR.go
  92. 351 218
      cmd/generate_resources.go
  93. 3 1
      cmd/translator.tmpl
  94. 1 0
      cs/cs.go
  95. 1 0
      cs_CZ/cs_CZ.go
  96. 1 0
      cu/cu.go
  97. 1 0
      cu_RU/cu_RU.go
  98. 1 0
      cy/cy.go
  99. 1 0
      cy_GB/cy_GB.go
  100. 1 0
      da/da.go

File diff suppressed because it is too large
+ 1 - 0
af/af.go


File diff suppressed because it is too large
+ 1 - 0
af_NA/af_NA.go


File diff suppressed because it is too large
+ 1 - 0
af_ZA/af_ZA.go


File diff suppressed because it is too large
+ 1 - 0
agq/agq.go


File diff suppressed because it is too large
+ 1 - 0
agq_CM/agq_CM.go


File diff suppressed because it is too large
+ 1 - 0
ak/ak.go


File diff suppressed because it is too large
+ 1 - 0
ak_GH/ak_GH.go


File diff suppressed because it is too large
+ 1 - 0
am/am.go


File diff suppressed because it is too large
+ 1 - 0
am_ET/am_ET.go


File diff suppressed because it is too large
+ 1 - 0
ar/ar.go


File diff suppressed because it is too large
+ 1 - 0
ar_001/ar_001.go


File diff suppressed because it is too large
+ 1 - 0
ar_AE/ar_AE.go


File diff suppressed because it is too large
+ 1 - 0
ar_BH/ar_BH.go


File diff suppressed because it is too large
+ 1 - 0
ar_DJ/ar_DJ.go


File diff suppressed because it is too large
+ 1 - 0
ar_DZ/ar_DZ.go


File diff suppressed because it is too large
+ 1 - 0
ar_EG/ar_EG.go


File diff suppressed because it is too large
+ 1 - 0
ar_EH/ar_EH.go


File diff suppressed because it is too large
+ 1 - 0
ar_ER/ar_ER.go


File diff suppressed because it is too large
+ 1 - 0
ar_IL/ar_IL.go


File diff suppressed because it is too large
+ 1 - 0
ar_IQ/ar_IQ.go


File diff suppressed because it is too large
+ 1 - 0
ar_JO/ar_JO.go


File diff suppressed because it is too large
+ 1 - 0
ar_KM/ar_KM.go


File diff suppressed because it is too large
+ 1 - 0
ar_KW/ar_KW.go


File diff suppressed because it is too large
+ 1 - 0
ar_LB/ar_LB.go


File diff suppressed because it is too large
+ 1 - 0
ar_LY/ar_LY.go


File diff suppressed because it is too large
+ 1 - 0
ar_MA/ar_MA.go


File diff suppressed because it is too large
+ 1 - 0
ar_MR/ar_MR.go


File diff suppressed because it is too large
+ 1 - 0
ar_OM/ar_OM.go


File diff suppressed because it is too large
+ 1 - 0
ar_PS/ar_PS.go


File diff suppressed because it is too large
+ 1 - 0
ar_QA/ar_QA.go


File diff suppressed because it is too large
+ 1 - 0
ar_SA/ar_SA.go


File diff suppressed because it is too large
+ 1 - 0
ar_SD/ar_SD.go


File diff suppressed because it is too large
+ 1 - 0
ar_SO/ar_SO.go


File diff suppressed because it is too large
+ 1 - 0
ar_SS/ar_SS.go


File diff suppressed because it is too large
+ 1 - 0
ar_SY/ar_SY.go


File diff suppressed because it is too large
+ 1 - 0
ar_TD/ar_TD.go


File diff suppressed because it is too large
+ 1 - 0
ar_TN/ar_TN.go


File diff suppressed because it is too large
+ 1 - 0
ar_YE/ar_YE.go


File diff suppressed because it is too large
+ 1 - 0
as/as.go


File diff suppressed because it is too large
+ 1 - 0
as_IN/as_IN.go


File diff suppressed because it is too large
+ 1 - 0
asa/asa.go


File diff suppressed because it is too large
+ 1 - 0
asa_TZ/asa_TZ.go


File diff suppressed because it is too large
+ 1 - 0
ast/ast.go


File diff suppressed because it is too large
+ 1 - 0
ast_ES/ast_ES.go


File diff suppressed because it is too large
+ 1 - 0
az/az.go


File diff suppressed because it is too large
+ 1 - 0
az_Cyrl/az_Cyrl.go


File diff suppressed because it is too large
+ 1 - 0
az_Cyrl_AZ/az_Cyrl_AZ.go


File diff suppressed because it is too large
+ 1 - 0
az_Latn/az_Latn.go


File diff suppressed because it is too large
+ 1 - 0
az_Latn_AZ/az_Latn_AZ.go


File diff suppressed because it is too large
+ 1 - 0
bas/bas.go


File diff suppressed because it is too large
+ 1 - 0
bas_CM/bas_CM.go


File diff suppressed because it is too large
+ 1 - 0
be/be.go


File diff suppressed because it is too large
+ 1 - 0
be_BY/be_BY.go


File diff suppressed because it is too large
+ 1 - 0
bem/bem.go


File diff suppressed because it is too large
+ 1 - 0
bem_ZM/bem_ZM.go


File diff suppressed because it is too large
+ 1 - 0
bez/bez.go


File diff suppressed because it is too large
+ 1 - 0
bez_TZ/bez_TZ.go


File diff suppressed because it is too large
+ 1 - 0
bg/bg.go


File diff suppressed because it is too large
+ 1 - 0
bg_BG/bg_BG.go


File diff suppressed because it is too large
+ 1 - 0
bm/bm.go


File diff suppressed because it is too large
+ 1 - 0
bm_ML/bm_ML.go


File diff suppressed because it is too large
+ 1 - 0
bn/bn.go


File diff suppressed because it is too large
+ 1 - 0
bn_BD/bn_BD.go


File diff suppressed because it is too large
+ 1 - 0
bn_IN/bn_IN.go


File diff suppressed because it is too large
+ 1 - 0
bo/bo.go


File diff suppressed because it is too large
+ 1 - 0
bo_CN/bo_CN.go


File diff suppressed because it is too large
+ 1 - 0
bo_IN/bo_IN.go


File diff suppressed because it is too large
+ 1 - 0
br/br.go


File diff suppressed because it is too large
+ 1 - 0
br_FR/br_FR.go


File diff suppressed because it is too large
+ 1 - 0
brx/brx.go


File diff suppressed because it is too large
+ 1 - 0
brx_IN/brx_IN.go


File diff suppressed because it is too large
+ 1 - 0
bs/bs.go


File diff suppressed because it is too large
+ 1 - 0
bs_Cyrl/bs_Cyrl.go


File diff suppressed because it is too large
+ 1 - 0
bs_Cyrl_BA/bs_Cyrl_BA.go


File diff suppressed because it is too large
+ 1 - 0
bs_Latn/bs_Latn.go


File diff suppressed because it is too large
+ 1 - 0
bs_Latn_BA/bs_Latn_BA.go


File diff suppressed because it is too large
+ 1 - 0
ca/ca.go


File diff suppressed because it is too large
+ 1 - 0
ca_AD/ca_AD.go


File diff suppressed because it is too large
+ 1 - 0
ca_ES/ca_ES.go


File diff suppressed because it is too large
+ 1 - 0
ca_ES_VALENCIA/ca_ES_VALENCIA.go


File diff suppressed because it is too large
+ 1 - 0
ca_FR/ca_FR.go


File diff suppressed because it is too large
+ 1 - 0
ca_IT/ca_IT.go


File diff suppressed because it is too large
+ 1 - 0
ce/ce.go


File diff suppressed because it is too large
+ 1 - 0
ce_RU/ce_RU.go


File diff suppressed because it is too large
+ 1 - 0
cgg/cgg.go


File diff suppressed because it is too large
+ 1 - 0
cgg_UG/cgg_UG.go


File diff suppressed because it is too large
+ 1 - 0
chr/chr.go


File diff suppressed because it is too large
+ 1 - 0
chr_US/chr_US.go


File diff suppressed because it is too large
+ 1 - 0
ckb/ckb.go


File diff suppressed because it is too large
+ 1 - 0
ckb_IQ/ckb_IQ.go


File diff suppressed because it is too large
+ 1 - 0
ckb_IR/ckb_IR.go


+ 351 - 218
cmd/generate_resources.go

@@ -124,6 +124,8 @@ type translator struct {
 	FmtErasNarrow      string
 	FmtErasWide        string
 
+	FmtTimezones string
+
 	// calculation only fields below this point...
 	DecimalNumberFormat          string
 	PercentNumberFormat          string
@@ -141,13 +143,17 @@ type translator struct {
 	FmtTimeLong   string
 	FmtTimeMedium string
 	FmtTimeShort  string
+
+	// timezones per locale by type
+	timezones map[string]*zoneAbbrev // key = type eg. America_Eastern zone Abbrev will be long form eg. Eastern Standard Time, Pacific Standard Time.....
 }
 
-// // IdxValue contains the index and string of types eg. months, days...
-// type IdxValue struct {
-// 	Idx   int
-// 	Value string
-// }
+type zoneAbbrev struct {
+	standard string
+	daylight string
+}
+
+var timezones = map[string]*zoneAbbrev{} // key = type eg. America_Eastern zone Abbrev eg. EST & EDT
 
 func main() {
 
@@ -215,6 +221,12 @@ func main() {
 
 		fmt.Println("Writing Data:", trans.Locale)
 
+		// for k, v := range trans.timezones {
+		// 	fmt.Println("\t-", k)
+		// 	fmt.Println("\t\t-", v.standard)
+		// 	fmt.Println("\t\t-", v.daylight)
+		// }
+
 		if err = os.MkdirAll(fmt.Sprintf(locDir, trans.Locale), 0777); err != nil {
 			log.Fatal(err)
 		}
@@ -249,6 +261,14 @@ func main() {
 
 func postProcess(cldr *cldr.CLDR) {
 
+	for _, v := range timezones {
+
+		// no DST
+		if len(v.daylight) == 0 {
+			v.daylight = v.standard
+		}
+	}
+
 	var base *translator
 	var found bool
 
@@ -262,9 +282,8 @@ func postProcess(cldr *cldr.CLDR) {
 		//ordinal plural rules
 		trans.OrdinalFunc, trans.PluralsOrdinal = parseOrdinalPluralRuleFunc(cldr, trans.BaseLocale)
 
-		// if trans.Locale == "en" {
+		// range plural rules
 		trans.RangeFunc = parseRangePluralRuleFunc(cldr, trans.BaseLocale)
-		// }
 
 		// ignore base locales
 		if trans.BaseLocale == trans.Locale {
@@ -506,6 +525,27 @@ func postProcess(cldr *cldr.CLDR) {
 
 		trans.Currencies = fmt.Sprintf("%#v", currencies)
 
+		// timezones
+
+		if (trans.timezones == nil || len(trans.timezones) == 0) && found {
+			trans.timezones = base.timezones
+		}
+
+		// make sure all base timezones are part of sub locale timezones
+		if found {
+
+			var ok bool
+
+			for k, v := range base.timezones {
+
+				if _, ok = trans.timezones[k]; ok {
+					continue
+				}
+
+				trans.timezones[k] = v
+			}
+		}
+
 		parseDecimalNumberFormat(trans)
 		parsePercentNumberFormat(trans)
 		parseCurrencyNumberFormat(trans)
@@ -515,6 +555,27 @@ func postProcess(cldr *cldr.CLDR) {
 
 		fmt.Println("Final Processing:", trans.Locale)
 
+		// if it's still nill.....
+		if trans.timezones == nil {
+			trans.timezones = make(map[string]*zoneAbbrev)
+		}
+
+		tz := make(map[string][]byte) // key = abbrev locale eg. EST, EDT, MST, PST... value = long locale eg. Eastern Standard Time, Pacific Time.....
+
+		for k, v := range timezones {
+
+			ttz, ok := trans.timezones[k]
+			if !ok {
+				ttz = v
+				trans.timezones[k] = v
+			}
+
+			tz[v.standard] = []byte(ttz.standard)
+			tz[v.daylight] = []byte(ttz.daylight)
+		}
+
+		trans.FmtTimezones = fmt.Sprintf("%#v", tz)
+
 		if len(trans.TimeSeparator) == 0 {
 			trans.TimeSeparator = fmt.Sprintf("%#v", []byte(":"))
 		}
@@ -647,294 +708,352 @@ func preProcess(cldrVar *cldr.CLDR) {
 			}
 		}
 
-		if ldml.Dates != nil && ldml.Dates.Calendars != nil {
+		if ldml.Dates != nil {
+
+			if ldml.Dates.TimeZoneNames != nil {
 
-			var calendar *cldr.Calendar
+				for _, zone := range ldml.Dates.TimeZoneNames.Metazone {
 
-			for _, cal := range ldml.Dates.Calendars.Calendar {
-				if cal.Type == "gregorian" {
-					calendar = cal
+					for _, short := range zone.Short {
+
+						if len(short.Standard) > 0 {
+							za, ok := timezones[zone.Type]
+							if !ok {
+								za = new(zoneAbbrev)
+								timezones[zone.Type] = za
+							}
+							za.standard = short.Standard[0].Data()
+						}
+
+						if len(short.Daylight) > 0 {
+							za, ok := timezones[zone.Type]
+							if !ok {
+								za = new(zoneAbbrev)
+								timezones[zone.Type] = za
+							}
+							za.daylight = short.Daylight[0].Data()
+						}
+					}
+
+					for _, long := range zone.Long {
+
+						if trans.timezones == nil {
+							trans.timezones = make(map[string]*zoneAbbrev)
+						}
+
+						if len(long.Standard) > 0 {
+							za, ok := trans.timezones[zone.Type]
+							if !ok {
+								za = new(zoneAbbrev)
+								trans.timezones[zone.Type] = za
+							}
+							za.standard = long.Standard[0].Data()
+						}
+
+						za, ok := trans.timezones[zone.Type]
+						if !ok {
+							za = new(zoneAbbrev)
+							trans.timezones[zone.Type] = za
+						}
+
+						if len(long.Daylight) > 0 {
+							za.daylight = long.Daylight[0].Data()
+						} else {
+							za.daylight = za.standard
+						}
+					}
 				}
 			}
 
-			if calendar != nil {
+			if ldml.Dates.Calendars != nil {
+
+				var calendar *cldr.Calendar
+
+				for _, cal := range ldml.Dates.Calendars.Calendar {
+					if cal.Type == "gregorian" {
+						calendar = cal
+					}
+				}
+
+				if calendar != nil {
 
-				if calendar.DateFormats != nil {
+					if calendar.DateFormats != nil {
 
-					for _, datefmt := range calendar.DateFormats.DateFormatLength {
+						for _, datefmt := range calendar.DateFormats.DateFormatLength {
 
-						switch datefmt.Type {
-						case "full":
-							trans.FmtDateFull = datefmt.DateFormat[0].Pattern[0].Data()
+							switch datefmt.Type {
+							case "full":
+								trans.FmtDateFull = datefmt.DateFormat[0].Pattern[0].Data()
 
-						case "long":
-							trans.FmtDateLong = datefmt.DateFormat[0].Pattern[0].Data()
+							case "long":
+								trans.FmtDateLong = datefmt.DateFormat[0].Pattern[0].Data()
 
-						case "medium":
-							trans.FmtDateMedium = datefmt.DateFormat[0].Pattern[0].Data()
+							case "medium":
+								trans.FmtDateMedium = datefmt.DateFormat[0].Pattern[0].Data()
 
-						case "short":
-							trans.FmtDateShort = datefmt.DateFormat[0].Pattern[0].Data()
+							case "short":
+								trans.FmtDateShort = datefmt.DateFormat[0].Pattern[0].Data()
+							}
 						}
 					}
-				}
 
-				if calendar.TimeFormats != nil {
+					if calendar.TimeFormats != nil {
 
-					for _, datefmt := range calendar.TimeFormats.TimeFormatLength {
+						for _, datefmt := range calendar.TimeFormats.TimeFormatLength {
 
-						switch datefmt.Type {
-						case "full":
-							trans.FmtTimeFull = datefmt.TimeFormat[0].Pattern[0].Data()
-						case "long":
-							trans.FmtTimeLong = datefmt.TimeFormat[0].Pattern[0].Data()
-						case "medium":
-							trans.FmtTimeMedium = datefmt.TimeFormat[0].Pattern[0].Data()
-						case "short":
-							trans.FmtTimeShort = datefmt.TimeFormat[0].Pattern[0].Data()
+							switch datefmt.Type {
+							case "full":
+								trans.FmtTimeFull = datefmt.TimeFormat[0].Pattern[0].Data()
+							case "long":
+								trans.FmtTimeLong = datefmt.TimeFormat[0].Pattern[0].Data()
+							case "medium":
+								trans.FmtTimeMedium = datefmt.TimeFormat[0].Pattern[0].Data()
+							case "short":
+								trans.FmtTimeShort = datefmt.TimeFormat[0].Pattern[0].Data()
+							}
 						}
 					}
-				}
 
-				if calendar.Months != nil {
+					if calendar.Months != nil {
 
-					// month context starts at 'format', but there is also has 'stand-alone'
-					// I'm making the decision to use the 'stand-alone' if, and only if,
-					// the value does not exist in the 'format' month context
-					var abbrSet, narrSet, shortSet, wideSet bool
+						// month context starts at 'format', but there is also has 'stand-alone'
+						// I'm making the decision to use the 'stand-alone' if, and only if,
+						// the value does not exist in the 'format' month context
+						var abbrSet, narrSet, shortSet, wideSet bool
 
-					for _, monthctx := range calendar.Months.MonthContext {
+						for _, monthctx := range calendar.Months.MonthContext {
 
-						for _, months := range monthctx.MonthWidth {
+							for _, months := range monthctx.MonthWidth {
 
-							var monthData [][]byte
+								var monthData [][]byte
 
-							for _, m := range months.Month {
+								for _, m := range months.Month {
 
-								if len(m.Data()) == 0 {
-									continue
+									if len(m.Data()) == 0 {
+										continue
+									}
+
+									switch m.Type {
+									case "1":
+										monthData = append(monthData, []byte(m.Data()))
+									case "2":
+										monthData = append(monthData, []byte(m.Data()))
+									case "3":
+										monthData = append(monthData, []byte(m.Data()))
+									case "4":
+										monthData = append(monthData, []byte(m.Data()))
+									case "5":
+										monthData = append(monthData, []byte(m.Data()))
+									case "6":
+										monthData = append(monthData, []byte(m.Data()))
+									case "7":
+										monthData = append(monthData, []byte(m.Data()))
+									case "8":
+										monthData = append(monthData, []byte(m.Data()))
+									case "9":
+										monthData = append(monthData, []byte(m.Data()))
+									case "10":
+										monthData = append(monthData, []byte(m.Data()))
+									case "11":
+										monthData = append(monthData, []byte(m.Data()))
+									case "12":
+										monthData = append(monthData, []byte(m.Data()))
+									}
 								}
 
-								switch m.Type {
-								case "1":
-									monthData = append(monthData, []byte(m.Data()))
-								case "2":
-									monthData = append(monthData, []byte(m.Data()))
-								case "3":
-									monthData = append(monthData, []byte(m.Data()))
-								case "4":
-									monthData = append(monthData, []byte(m.Data()))
-								case "5":
-									monthData = append(monthData, []byte(m.Data()))
-								case "6":
-									monthData = append(monthData, []byte(m.Data()))
-								case "7":
-									monthData = append(monthData, []byte(m.Data()))
-								case "8":
-									monthData = append(monthData, []byte(m.Data()))
-								case "9":
-									monthData = append(monthData, []byte(m.Data()))
-								case "10":
-									monthData = append(monthData, []byte(m.Data()))
-								case "11":
-									monthData = append(monthData, []byte(m.Data()))
-								case "12":
-									monthData = append(monthData, []byte(m.Data()))
+								if len(monthData) > 0 {
+
+									// making array indexes line up with month values
+									// so I'll have an extra empty value, it's way faster
+									// than a switch over all type values...
+									monthData = append(make([][]byte, 1, len(monthData)+1), monthData...)
+
+									switch months.Type {
+									case "abbreviated":
+										if !abbrSet {
+											abbrSet = true
+											trans.FmtMonthsAbbreviated = fmt.Sprintf("%#v", monthData)
+										}
+									case "narrow":
+										if !narrSet {
+											narrSet = true
+											trans.FmtMonthsNarrow = fmt.Sprintf("%#v", monthData)
+										}
+									case "short":
+										if !shortSet {
+											shortSet = true
+											trans.FmtMonthsShort = fmt.Sprintf("%#v", monthData)
+										}
+									case "wide":
+										if !wideSet {
+											wideSet = true
+											trans.FmtMonthsWide = fmt.Sprintf("%#v", monthData)
+										}
+									}
 								}
 							}
+						}
+					}
 
-							if len(monthData) > 0 {
+					if calendar.Days != nil {
 
-								// making array indexes line up with month values
-								// so I'll have an extra empty value, it's way faster
-								// than a switch over all type values...
-								monthData = append(make([][]byte, 1, len(monthData)+1), monthData...)
+						// day context starts at 'format', but there is also has 'stand-alone'
+						// I'm making the decision to use the 'stand-alone' if, and only if,
+						// the value does not exist in the 'format' day context
+						var abbrSet, narrSet, shortSet, wideSet bool
 
-								switch months.Type {
-								case "abbreviated":
-									if !abbrSet {
-										abbrSet = true
-										trans.FmtMonthsAbbreviated = fmt.Sprintf("%#v", monthData)
-									}
-								case "narrow":
-									if !narrSet {
-										narrSet = true
-										trans.FmtMonthsNarrow = fmt.Sprintf("%#v", monthData)
-									}
-								case "short":
-									if !shortSet {
-										shortSet = true
-										trans.FmtMonthsShort = fmt.Sprintf("%#v", monthData)
+						for _, dayctx := range calendar.Days.DayContext {
+
+							for _, days := range dayctx.DayWidth {
+
+								var dayData [][]byte
+
+								for _, d := range days.Day {
+
+									switch d.Type {
+									case "sun":
+										dayData = append(dayData, []byte(d.Data()))
+									case "mon":
+										dayData = append(dayData, []byte(d.Data()))
+									case "tue":
+										dayData = append(dayData, []byte(d.Data()))
+									case "wed":
+										dayData = append(dayData, []byte(d.Data()))
+									case "thu":
+										dayData = append(dayData, []byte(d.Data()))
+									case "fri":
+										dayData = append(dayData, []byte(d.Data()))
+									case "sat":
+										dayData = append(dayData, []byte(d.Data()))
 									}
-								case "wide":
-									if !wideSet {
-										wideSet = true
-										trans.FmtMonthsWide = fmt.Sprintf("%#v", monthData)
+								}
+
+								if len(dayData) > 0 {
+									switch days.Type {
+									case "abbreviated":
+										if !abbrSet {
+											abbrSet = true
+											trans.FmtDaysAbbreviated = fmt.Sprintf("%#v", dayData)
+										}
+									case "narrow":
+										if !narrSet {
+											narrSet = true
+											trans.FmtDaysNarrow = fmt.Sprintf("%#v", dayData)
+										}
+									case "short":
+										if !shortSet {
+											shortSet = true
+											trans.FmtDaysShort = fmt.Sprintf("%#v", dayData)
+										}
+									case "wide":
+										if !wideSet {
+											wideSet = true
+											trans.FmtDaysWide = fmt.Sprintf("%#v", dayData)
+										}
 									}
 								}
 							}
 						}
 					}
-				}
 
-				if calendar.Days != nil {
+					if calendar.DayPeriods != nil {
 
-					// day context starts at 'format', but there is also has 'stand-alone'
-					// I'm making the decision to use the 'stand-alone' if, and only if,
-					// the value does not exist in the 'format' day context
-					var abbrSet, narrSet, shortSet, wideSet bool
+						// day periods context starts at 'format', but there is also has 'stand-alone'
+						// I'm making the decision to use the 'stand-alone' if, and only if,
+						// the value does not exist in the 'format' day period context
+						var abbrSet, narrSet, shortSet, wideSet bool
 
-					for _, dayctx := range calendar.Days.DayContext {
+						for _, ctx := range calendar.DayPeriods.DayPeriodContext {
 
-						for _, days := range dayctx.DayWidth {
+							for _, width := range ctx.DayPeriodWidth {
 
-							var dayData [][]byte
+								// [0] = AM
+								// [0] = PM
+								ampm := make([][]byte, 2, 2)
 
-							for _, d := range days.Day {
+								for _, d := range width.DayPeriod {
+
+									if d.Type == "am" {
+										ampm[0] = []byte(d.Data())
+										continue
+									}
 
-								switch d.Type {
-								case "sun":
-									dayData = append(dayData, []byte(d.Data()))
-								case "mon":
-									dayData = append(dayData, []byte(d.Data()))
-								case "tue":
-									dayData = append(dayData, []byte(d.Data()))
-								case "wed":
-									dayData = append(dayData, []byte(d.Data()))
-								case "thu":
-									dayData = append(dayData, []byte(d.Data()))
-								case "fri":
-									dayData = append(dayData, []byte(d.Data()))
-								case "sat":
-									dayData = append(dayData, []byte(d.Data()))
+									if d.Type == "pm" {
+										ampm[1] = []byte(d.Data())
+									}
 								}
-							}
 
-							if len(dayData) > 0 {
-								switch days.Type {
+								switch width.Type {
 								case "abbreviated":
 									if !abbrSet {
 										abbrSet = true
-										trans.FmtDaysAbbreviated = fmt.Sprintf("%#v", dayData)
+										trans.FmtPeriodsAbbreviated = fmt.Sprintf("%#v", ampm)
 									}
 								case "narrow":
 									if !narrSet {
 										narrSet = true
-										trans.FmtDaysNarrow = fmt.Sprintf("%#v", dayData)
+										trans.FmtPeriodsNarrow = fmt.Sprintf("%#v", ampm)
 									}
 								case "short":
 									if !shortSet {
 										shortSet = true
-										trans.FmtDaysShort = fmt.Sprintf("%#v", dayData)
+										trans.FmtPeriodsShort = fmt.Sprintf("%#v", ampm)
 									}
 								case "wide":
 									if !wideSet {
 										wideSet = true
-										trans.FmtDaysWide = fmt.Sprintf("%#v", dayData)
+										trans.FmtPeriodsWide = fmt.Sprintf("%#v", ampm)
 									}
 								}
 							}
 						}
 					}
-				}
-
-				if calendar.DayPeriods != nil {
 
-					// day periods context starts at 'format', but there is also has 'stand-alone'
-					// I'm making the decision to use the 'stand-alone' if, and only if,
-					// the value does not exist in the 'format' day period context
-					var abbrSet, narrSet, shortSet, wideSet bool
+					if calendar.Eras != nil {
 
-					for _, ctx := range calendar.DayPeriods.DayPeriodContext {
+						// [0] = BC
+						// [0] = AD
+						abbrev := make([][]byte, 2, 2)
+						narr := make([][]byte, 2, 2)
+						wide := make([][]byte, 2, 2)
 
-						for _, width := range ctx.DayPeriodWidth {
-
-							// [0] = AM
-							// [0] = PM
-							ampm := make([][]byte, 2, 2)
-
-							for _, d := range width.DayPeriod {
-
-								if d.Type == "am" {
-									ampm[0] = []byte(d.Data())
-									continue
-								}
+						if calendar.Eras.EraAbbr != nil {
 
-								if d.Type == "pm" {
-									ampm[1] = []byte(d.Data())
-								}
-							}
-
-							switch width.Type {
-							case "abbreviated":
-								if !abbrSet {
-									abbrSet = true
-									trans.FmtPeriodsAbbreviated = fmt.Sprintf("%#v", ampm)
-								}
-							case "narrow":
-								if !narrSet {
-									narrSet = true
-									trans.FmtPeriodsNarrow = fmt.Sprintf("%#v", ampm)
-								}
-							case "short":
-								if !shortSet {
-									shortSet = true
-									trans.FmtPeriodsShort = fmt.Sprintf("%#v", ampm)
-								}
-							case "wide":
-								if !wideSet {
-									wideSet = true
-									trans.FmtPeriodsWide = fmt.Sprintf("%#v", ampm)
-								}
+							if len(calendar.Eras.EraAbbr.Era) == 4 {
+								abbrev[0] = []byte(calendar.Eras.EraAbbr.Era[0].Data())
+								abbrev[1] = []byte(calendar.Eras.EraAbbr.Era[2].Data())
+							} else if len(calendar.Eras.EraAbbr.Era) == 2 {
+								abbrev[0] = []byte(calendar.Eras.EraAbbr.Era[0].Data())
+								abbrev[1] = []byte(calendar.Eras.EraAbbr.Era[1].Data())
 							}
 						}
-					}
-				}
-
-				if calendar.Eras != nil {
-
-					// [0] = BC
-					// [0] = AD
-					abbrev := make([][]byte, 2, 2)
-					narr := make([][]byte, 2, 2)
-					wide := make([][]byte, 2, 2)
 
-					if calendar.Eras.EraAbbr != nil {
+						if calendar.Eras.EraNarrow != nil {
 
-						if len(calendar.Eras.EraAbbr.Era) == 4 {
-							abbrev[0] = []byte(calendar.Eras.EraAbbr.Era[0].Data())
-							abbrev[1] = []byte(calendar.Eras.EraAbbr.Era[2].Data())
-						} else if len(calendar.Eras.EraAbbr.Era) == 2 {
-							abbrev[0] = []byte(calendar.Eras.EraAbbr.Era[0].Data())
-							abbrev[1] = []byte(calendar.Eras.EraAbbr.Era[1].Data())
+							if len(calendar.Eras.EraNarrow.Era) == 4 {
+								narr[0] = []byte(calendar.Eras.EraNarrow.Era[0].Data())
+								narr[1] = []byte(calendar.Eras.EraNarrow.Era[2].Data())
+							} else if len(calendar.Eras.EraNarrow.Era) == 2 {
+								narr[0] = []byte(calendar.Eras.EraNarrow.Era[0].Data())
+								narr[1] = []byte(calendar.Eras.EraNarrow.Era[1].Data())
+							}
 						}
-					}
 
-					if calendar.Eras.EraNarrow != nil {
+						if calendar.Eras.EraNames != nil {
 
-						if len(calendar.Eras.EraNarrow.Era) == 4 {
-							narr[0] = []byte(calendar.Eras.EraNarrow.Era[0].Data())
-							narr[1] = []byte(calendar.Eras.EraNarrow.Era[2].Data())
-						} else if len(calendar.Eras.EraNarrow.Era) == 2 {
-							narr[0] = []byte(calendar.Eras.EraNarrow.Era[0].Data())
-							narr[1] = []byte(calendar.Eras.EraNarrow.Era[1].Data())
+							if len(calendar.Eras.EraNames.Era) == 4 {
+								wide[0] = []byte(calendar.Eras.EraNames.Era[0].Data())
+								wide[1] = []byte(calendar.Eras.EraNames.Era[2].Data())
+							} else if len(calendar.Eras.EraNames.Era) == 2 {
+								wide[0] = []byte(calendar.Eras.EraNames.Era[0].Data())
+								wide[1] = []byte(calendar.Eras.EraNames.Era[1].Data())
+							}
 						}
-					}
 
-					if calendar.Eras.EraNames != nil {
-
-						if len(calendar.Eras.EraNames.Era) == 4 {
-							wide[0] = []byte(calendar.Eras.EraNames.Era[0].Data())
-							wide[1] = []byte(calendar.Eras.EraNames.Era[2].Data())
-						} else if len(calendar.Eras.EraNames.Era) == 2 {
-							wide[0] = []byte(calendar.Eras.EraNames.Era[0].Data())
-							wide[1] = []byte(calendar.Eras.EraNames.Era[1].Data())
-						}
+						trans.FmtErasAbbreviated = fmt.Sprintf("%#v", abbrev)
+						trans.FmtErasNarrow = fmt.Sprintf("%#v", narr)
+						trans.FmtErasWide = fmt.Sprintf("%#v", wide)
 					}
-
-					trans.FmtErasAbbreviated = fmt.Sprintf("%#v", abbrev)
-					trans.FmtErasNarrow = fmt.Sprintf("%#v", narr)
-					trans.FmtErasWide = fmt.Sprintf("%#v", wide)
 				}
 			}
 		}
@@ -1181,11 +1300,25 @@ func parseDateTimeFormat(baseLocale, format string) (results string) {
 
 			// using the timezone on the Go time object, eg. EST, EDT, MST.....
 
-			results += `
-				tz, _ := t.Zone()
-				b = append(b, tz...)
+			if count < 4 {
 
-			`
+				results += `
+					tz, _ := t.Zone()
+					b = append(b, tz...)
+
+				`
+			} else {
+
+				results += `
+					tz, _ := t.Zone()
+					if btz, ok := ` + baseLocale + `.timezones[tz]; ok {
+						b = append(b, btz...)
+					} else {
+						b = append(b, tz...)
+					}
+
+				`
+			}
 
 		// day
 		case 'd':

+ 3 - 1
cmd/translator.tmpl

@@ -42,6 +42,7 @@ type {{ .Locale }} struct {
 	erasAbbreviated        [][]byte
 	erasNarrow      	   [][]byte
 	erasWide      	   	   [][]byte
+	timezones 			   map[string][]byte
 }
 
 // New returns a new instance of translator for the '{{ .Locale }}' locale
@@ -124,7 +125,8 @@ func New() locales.Translator {
 		{{- end -}}
 		{{- if gt (len .FmtErasWide) 0 }}
 		erasWide:   {{ .FmtErasWide }},
-		{{- end}}
+		{{- end }}
+		timezones: {{ .FmtTimezones }},
 	}
 }
 

File diff suppressed because it is too large
+ 1 - 0
cs/cs.go


File diff suppressed because it is too large
+ 1 - 0
cs_CZ/cs_CZ.go


File diff suppressed because it is too large
+ 1 - 0
cu/cu.go


File diff suppressed because it is too large
+ 1 - 0
cu_RU/cu_RU.go


File diff suppressed because it is too large
+ 1 - 0
cy/cy.go


File diff suppressed because it is too large
+ 1 - 0
cy_GB/cy_GB.go


File diff suppressed because it is too large
+ 1 - 0
da/da.go


Some files were not shown because too many files changed in this diff