Documentation ¶
Index ¶
- Variables
- type LocaleDetails
- func (ld *LocaleDetails) GetMonthNumber(month string) int
- func (ld *LocaleDetails) GetMonthShortNumber(month string) int
- func (ld *LocaleDetails) GetWeekdayMinNumber(wd string) int
- func (ld *LocaleDetails) GetWeekdayNumber(wd string) int
- func (ld *LocaleDetails) GetWeekdayShortNumber(wd string) int
- func (ld *LocaleDetails) GetWeekdays(shifted bool) []string
- func (ld *LocaleDetails) GetWeekdaysMin(shifted bool) []string
- func (ld *LocaleDetails) GetWeekdaysShort(shifted bool) []string
- func (ld *LocaleDetails) LongDateFormat(key string) (string, bool)
- func (ld *LocaleDetails) RelativeTime(format string, number int, withoutSuffix bool, past bool) string
Constants ¶
This section is empty.
Variables ¶
var EnLocale = newLocale( "en", strings.Split("Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday", "_"), strings.Split("Sun_Mon_Tue_Wed_Thu_Fri_Sat", "_"), strings.Split("Su_Mo_Tu_We_Th_Fr_Sa", "_"), strings.Split("January_February_March_April_May_June_July_August_September_October_November_December", "_"), strings.Split("Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec", "_"), func(num int, period string) string { suffix := "th" switch num % 10 { case 1: if num%100 != 11 { suffix = "st" } case 2: if num%100 != 12 { suffix = "nd" } case 3: if num%100 != 13 { suffix = "rd" } } return strconv.Itoa(num) + suffix }, nil, week{Dow: 0, Doy: 6}, longDateFormats{ "LTS": "h:mm:ss A", "LT": "h:mm A", "L": "MM/DD/YYYY", "LL": "MMMM D, YYYY", "LLL": "MMMM D, YYYY h:mm A", "LLLL": "dddd, MMMM D, YYYY h:mm A", }, relativeTimeFormats{ "future": "in %s", "past": "%s ago", "s": "a few seconds", "ss": "%d seconds", "m": "a minute", "mm": "%d minutes", "h": "an hour", "hh": "%d hours", "d": "a day", "dd": "%d days", "M": "a month", "MM": "%d months", "y": "a year", "yy": "%d years", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[Today at] LT" }, "nextDay": func(hours int, day int) string { return "[Tomorrow at] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [at] LT" }, "lastDay": func(hours int, day int) string { return "[Yesterday at] LT" }, "lastWeek": func(hours int, day int) string { return "[Last] dddd [at] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(January|February|March|April|May|June|July|August|September|October|November|December)`, `(?i)(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)`, `(?i)(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)`, `(?i)(Sun|Mon|Tue|Wed|Thu|Fri|Sat)`, `(?i)(Su|Mo|Tu|We|Th|Fr|Sa)`, `\d{1,2}(th|st|nd|rd)`, )
EnLocale is the US English language locale.
var EsLocale = newLocale( "es", strings.Split("domingo_lunes_martes_miércoles_jueves_viernes_sábado", "_"), strings.Split("dom._lun._mar._mié._jue._vie._sáb.", "_"), strings.Split("do_lu_ma_mi_ju_vi_sá", "_"), strings.Split("enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre", "_"), strings.Split("ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic", "_"), func(num int, period string) string { return fmt.Sprintf("%dº", num) }, nil, week{Dow: 1, Doy: 4}, longDateFormats{ "LTS": "H:mm:ss", "LT": "H:mm", "L": "DD/MM/YYYY", "LL": "D [de] MMMM [de] YYYY", "LLL": "D [de] MMMM [de] YYYY H:mm", "LLLL": "dddd, D [de] MMMM [de] YYYY H:mm", }, relativeTimeFormats{ "future": "en %s", "past": "hace %s", "s": "unos segundos", "ss": "%d segundos", "m": "un minuto", "mm": "%d minutos", "h": "una hora", "hh": "%d horas", "d": "un día", "dd": "%d días", "M": "un mes", "MM": "%d meses", "y": "un año", "yy": "%d años", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[hoy a " + getEsCalendarPronoun(hours) + "] LT" }, "nextDay": func(hours int, day int) string { return "[mañana a " + getEsCalendarPronoun(hours) + "] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [a " + getEsCalendarPronoun(hours) + "] LT" }, "lastDay": func(hours int, day int) string { return "[ayer a " + getEsCalendarPronoun(hours) + "] LT" }, "lastWeek": func(hours int, day int) string { return "[el] dddd [pasado a " + getEsCalendarPronoun(hours) + "] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)`, `(?i)(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)`, `(?i)(domingo|lunes|martes|miércoles|jueves|viernes|sábado)`, `(?i)(dom\.?|lun\.?|mar\.?|mié\.?|jue\.?|vie\.?|sáb\.?)`, `(?i)(do|lu|ma|mi|ju|vi|sá)`, `\d{1,2}º`, )
EsLocale is the Spanish language locale.
var FaLocale = newLocale( "fa", strings.Split("یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه", "_"), strings.Split("یک_دو_سه_چهار_پنج_جمعه_شنبه", "_"), strings.Split("یک_دو_سه_چه_پن_جم_شن", "_"), strings.Split("ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر", "_"), strings.Split("ژان_فور_مار_آور_مه_ژون_ژوئ_اوت_سپت_اکت_نوا_دسا", "_"), func(num int, period string) string { return fmt.Sprintf("%d روز", num) }, nil, week{Dow: 0, Doy: 6}, longDateFormats{ "LTS": "h:mm:ss A", "LT": "h:mm A", "L": "MM/DD/YYYY", "LL": "MMMM D, YYYY", "LLL": "MMMM D, YYYY h:mm A", "LLLL": "dddd, MMMM D, YYYY h:mm A", }, relativeTimeFormats{ "future": "در %s", "past": "%s پیش", "s": "چند ثانیه پیش", "ss": "%d ثانیه", "m": "یک دقیقه", "mm": "%d دقیقه", "h": "یک ساعت", "hh": "%d ساعت", "d": "یک روز", "dd": "%d روز", "M": "یک ماه", "MM": "%d ماه", "y": "یک سال", "yy": "%d سال", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[امروز] LT" }, "nextDay": func(hours int, day int) string { return "[فردا] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [در ساعت] LT" }, "lastDay": func(hours int, day int) string { return "[دیروز] LT" }, "lastWeek": func(hours int, day int) string { return "[هفته پیش] dddd [در ساعت] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(ژانویه|فوریه|مارس|آوریل|مه|ژوئن|ژوئیه|اوت|سپتامبر|اکتبر|نوامبر|دسامبر)`, `(?i)(ژان|فور|مار|آور|مه|ژون|ژوئ|اوت|سپت|اکت|نوا|دسا)`, `(?i)(یکشنبه|دوشنبه|سهشنبه|چهارشنبه|پنجشنبه|جمعه|شنبه)`, `(?i)(یک|دو|سه|چهار|پنج|جمعه|شنبه)`, `(?i)(یک|دو|سه|چه|پن|جم|شن)`, `\d{1,2}روز`, )
FaLocale is the FA Persian language locale.
var FrLocale = newLocale( "fr", strings.Split("dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi", "_"), strings.Split("dim._lun._mar._mer._jeu._ven._sam.", "_"), strings.Split("di_lu_ma_me_je_ve_sa", "_"), strings.Split("janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre", "_"), strings.Split("janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.", "_"), func(num int, period string) string { suffix := "" switch period { case "D": if num == 1 { suffix = "er" } return strconv.Itoa(num) + suffix case "M", "Q", "DDD", "d": suffix = "e" if num == 1 { suffix = "er" } case "w", "W": suffix = "e" if num == 1 { suffix = "re" } default: suffix = "e" if num == 1 { suffix = "er" } } return strconv.Itoa(num) + suffix }, nil, week{Dow: 1, Doy: 4}, longDateFormats{ "LTS": "HH:mm:ss", "LT": "HH:mm", "L": "DD/MM/YYYY", "LL": "D MMMM YYYY", "LLL": "D MMMM YYYY HH:mm", "LLLL": "dddd D MMMM YYYY HH:mm", }, relativeTimeFormats{ "future": "dans %s", "past": "il y a %s", "s": "quelques secondes", "ss": "%d secondes", "m": "une minute", "mm": "%d minutes", "h": "une heure", "hh": "%d heures", "d": "un jour", "dd": "%d jours", "M": "un mois", "MM": "%d mois", "y": "un an", "yy": "%d ans", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[Aujourd’hui à] LT" }, "nextDay": func(hours int, day int) string { return "[Demain à] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [à] LT" }, "lastDay": func(hours int, day int) string { return "[Hier à] LT" }, "lastWeek": func(hours int, day int) string { return "dddd [dernier à] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)`, `(?i)(janv\.?|févr\.?|mars|avr\.?|mai|juin|juil\.?|août|sept\.?|oct\.?|nov\.?|déc\.?)`, `(?i)(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)`, `(?i)(dim\.?|lun\.?|mar\.?|mer\.?|jeu\.?|ven\.?|sam\.?)`, `(?i)(di|lu|ma|me|je|ve|sa)`, `\d{1,2}(er|)`, )
FrLocale is the French language locale.
var IdLocale = newLocale( "id", strings.Split("Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu", "_"), strings.Split("Min_Sen_Sel_Rab_Kam_Jum_Sab", "_"), strings.Split("Mg_Sn_Sl_Rb_Km_Jm_Sb", "_"), strings.Split("Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember", "_"), strings.Split("Jan_Feb_Mar_Apr_Mei_Jun_Jul_Agt_Sep_Okt_Nov_Des", "_"), func(num int, period string) string { return fmt.Sprintf("%d", num) }, func(hours int, minutes int, isLower bool) string { lowerOrTitle := func(word string) string { if isLower { return strings.ToLower(word) } return strings.Title(word) } switch { case hours < 5: return lowerOrTitle("dini hari") case hours < 11: return lowerOrTitle("pagi") case hours < 15: return lowerOrTitle("siang") case hours < 19: return lowerOrTitle("sore") default: return lowerOrTitle("malam") } }, week{Dow: 0, Doy: 6}, longDateFormats{ "LTS": "HH:mm:ss", "LT": "HH:mm", "L": "DD/MM/YYYY", "LL": "D MMMM YYYY", "LLL": "D MMMM YYYY, HH:mm", "LLLL": "dddd, D MMMM YYYY, HH:mm", }, relativeTimeFormats{ "future": "dalam %s", "past": "%s yang lalu", "s": "beberapa detik", "ss": "%d detik", "m": "semenit", "mm": "%d menit", "h": "sejam", "hh": "%d jam", "d": "sehari", "dd": "%d hari", "M": "sebulan", "MM": "%d bulan", "y": "setahun", "yy": "%d tahun", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[hari ini pukul] LT" }, "nextDay": func(hours int, day int) string { return "[besok pukul] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [pukul] LT" }, "lastDay": func(hours int, day int) string { return "[kemarin pukul] LT" }, "lastWeek": func(hours int, day int) string { return "dddd [lalu pukul] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(Januari|Februari|Maret|April|Mei|Juni|Juli|Agustus|September|Oktober|November|Desember)`, `(?i)(Jan|Feb|Mar|Apr|Mei|Jun|Jul|Agt|Sep|Okt|Nov|Des)`, `(?i)(Minggu|Senin|Selasa|Rabu|Kamis|Jumat|Sabtu)`, `(?i)(Min|Sen|Sel|Rab|Kam|Jum|Sab)`, `(?i)(Mg|Sn|Sl|Rb|Km|Jm|Sb)`, `\d{1,2}`, )
IdLocale is the Indonesian language locale.
var PtBRLocale = newLocale( "pt-br", strings.Split("domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado", "_"), strings.Split("dom_seg_ter_qua_qui_sex_sab", "_"), strings.Split("do_se_te_qa_qi_se_sa", "_"), strings.Split("janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro", "_"), strings.Split("jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez", "_"), func(num int, period string) string { return fmt.Sprintf("%dº", num) }, nil, week{Dow: 1, Doy: 4}, longDateFormats{ "LTS": "H:mm:ss", "LT": "H:mm", "L": "DD/MM/YYYY", "LL": "D [de] MMMM [de] YYYY", "LLL": "D [de] MMMM [de] YYYY H:mm", "LLLL": "dddd, D [de] MMMM [de] YYYY H:mm", }, relativeTimeFormats{ "future": "em %s", "past": "há %s", "s": "alguns segundos", "ss": "%d segundos", "m": "um minuto", "mm": "%d minutos", "h": "uma hora", "hh": "%d horas", "d": "um dia", "dd": "%d dias", "M": "um mês", "MM": "%d meses", "y": "um ano", "yy": "%d anos", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[hoje " + getPtBRCalendarPronoun(hours) + "] LT" }, "nextDay": func(hours int, day int) string { return "[amanhã " + getPtBRCalendarPronoun(hours) + "] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [" + getPtBRCalendarPronoun(hours) + "] LT" }, "lastDay": func(hours int, day int) string { return "[ontem " + getPtBRCalendarPronoun(hours) + "] LT" }, "lastWeek": func(hours int, day int) string { return "[na] dddd [passada " + getPtBRCalendarPronoun(hours) + "] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)`, `(?i)(jan\.?|fev\.?|mar\.?|abr\.?|mai\.?|jun\.?|jul\.?|ago\.?|set\.?|out\.?|nov\.?|dez\.?)`, `(?i)(domingo|segunda-feira|terça-feira|quarta-feira|quinta-feira|sexta-feira|sábado)`, `(?i)(dom\.?|seg\.?|ter\.?|qua\.?|qui\.?|sex\.?|sáb\.?)`, `(?i)(do|lu|ma|mi|ju|vi|sá)`, `\d{1,2}º`, )
PtBRLocale is the Brazilian Portuguese language locale.
var RuLocale = newLocale( "ru", strings.Split("Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота", "_"), strings.Split("Вс_Пн_Вт_Ср_Чт_Пт_Сб", "_"), strings.Split("Вс_Пн_Вт_Ср_Чт_Пт_Сб", "_"), strings.Split("Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь", "_"), strings.Split("Янв_Фев_Мар_Апр_Май_Июн_Июл_Авг_Сен_Окт_Ноя_Дек", "_"), func(num int, period string) string { suffix := "th" switch period { case "M": case "d": case "DDD": suffix = "-й" case "D": suffix = "-го" case "w": case "W": suffix = "-я" } return strconv.Itoa(num) + suffix }, nil, week{Dow: 1, Doy: 4}, longDateFormats{ "LTS": "H:mm:ss", "LT": "H:mm", "L": "DD.MM.YYYY", "LL": "D MMMM YYYY г.", "LLL": "D MMMM YYYY г., H:mm", "LLLL": "dddd, D MMMM YYYY г., H:mm", }, relativeTimeFormats{ "future": "через %s", "past": "%s назад", "s": "несколько секунд", "ss": "%d секунд", "m": "минуту", "mm": "%d минут", "h": "час", "hh": "%d часов", "d": "день", "dd": "%d дней", "M": "месяц", "MM": "%d месяцев", "y": "год", "yy": "%d года", }, calendarFunctions{ "sameDay": func(hours int, day int) string { return "[Сегодня в] LT" }, "nextDay": func(hours int, day int) string { return "[Завтра в] LT" }, "nextWeek": func(hours int, day int) string { return "dddd [в сл.] LT" }, "lastDay": func(hours int, day int) string { return "[Вчера в] LT" }, "lastWeek": func(hours int, day int) string { return "[В прошлый] dddd [в] LT" }, "sameElse": func(hours int, day int) string { return "L" }, }, `(?i)(Январь|Февраль|Март|Апрель|Май|Июнь|Июль|Август|Сентябрь|Октябрь|Ноябрь|Декабрь)`, `(?i)(Янв|Фев|Мар|Апр|Май|Июн|Июл|Авг|Сен|Окт|Ноя|Дек)`, `(?i)(Воскресенье|Понедельник|Вторник|Среда|Четверг|Пятница|Суббота)`, `(?i)(Вос|Пон|Вто|Сре|Чет|Пят|Суб)`, `(?i)(Вс|Пн|Вт|Ср|Чт|Пт|Сб)`, `\d{1,2}(й|го|я)`, )
RuLocale is the Russian language locale.
Functions ¶
This section is empty.
Types ¶
type LocaleDetails ¶
type LocaleDetails struct { Code string Weekdays []string WeekdaysMin []string WeekdaysShort []string Months []string MonthsShort []string OrdinalFunc ordinalFunction MeridiemFunc meridiemFunction Week week LongDateFormats longDateFormats RelativeTimes relativeTimeFormats Calendar calendarFunctions MonthsRegex *regexp.Regexp MonthsShortRegex *regexp.Regexp WeekdaysRegex *regexp.Regexp WeekdaysShortRegex *regexp.Regexp WeekdaysMinRegex *regexp.Regexp DayOfMonthOrdinalRegex *regexp.Regexp }
LocaleDetails contains the details of the loaded locale.
func (*LocaleDetails) GetMonthNumber ¶
func (ld *LocaleDetails) GetMonthNumber(month string) int
GetMonthNumber returns the number for the month name.
func (*LocaleDetails) GetMonthShortNumber ¶
func (ld *LocaleDetails) GetMonthShortNumber(month string) int
GetMonthShortNumber returns the number for the short month name.
func (*LocaleDetails) GetWeekdayMinNumber ¶
func (ld *LocaleDetails) GetWeekdayMinNumber(wd string) int
GetWeekdayMinNumber returns the number for the min weekday name.
func (*LocaleDetails) GetWeekdayNumber ¶
func (ld *LocaleDetails) GetWeekdayNumber(wd string) int
GetWeekdayNumber returns the number for the weekday name.
func (*LocaleDetails) GetWeekdayShortNumber ¶
func (ld *LocaleDetails) GetWeekdayShortNumber(wd string) int
GetWeekdayShortNumber returns the number for the short weekday name.
func (*LocaleDetails) GetWeekdays ¶
func (ld *LocaleDetails) GetWeekdays(shifted bool) []string
GetWeekdays returns the list of weekdays for the locale. If the shifted param is true, the weekdays will take the DayOfWeek for the locale and shift the weekdays so the first DayOfWeek is 0,
func (*LocaleDetails) GetWeekdaysMin ¶
func (ld *LocaleDetails) GetWeekdaysMin(shifted bool) []string
GetWeekdaysMin returns the list of min weekdays for the locale. If the shifted param is true, the min weekdays will take the DayOfWeek for the locale and shift the min weekdays so the first DayOfWeek is 0,
func (*LocaleDetails) GetWeekdaysShort ¶
func (ld *LocaleDetails) GetWeekdaysShort(shifted bool) []string
GetWeekdaysShort returns the list of short weekdays for the locale. If the shifted param is true, the short weekdays will take the DayOfWeek for the locale and shift the short weekdays so the first DayOfWeek is 0,
func (*LocaleDetails) LongDateFormat ¶
func (ld *LocaleDetails) LongDateFormat(key string) (string, bool)
LongDateFormat returns the format for the matching long date token.
func (*LocaleDetails) RelativeTime ¶
func (ld *LocaleDetails) RelativeTime(format string, number int, withoutSuffix bool, past bool) string
RelativeTime returns the relative time for the period.