From 08de2bf51a5feb842a99b1cedd62708aeeca52be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amadeo=20Garc=C3=ADa=20Torrano?= Date: Wed, 30 Dec 2020 11:25:18 -0300 Subject: [PATCH 1/5] Final Spanish corrections In my opinion with this commit we can close the issue #533. I edited `es.txt` and `es-help.txt` in `share/translations`. `we-lang.go` was okay, so I didn't touch it. I apologize for being absent the last 2 months after suggesting said issue. --- share/translations/es-help.txt | 58 +++++++++++++++++----------------- share/translations/es.txt | 6 ++-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/share/translations/es-help.txt b/share/translations/es-help.txt index 07f2c34..5c69490 100644 --- a/share/translations/es-help.txt +++ b/share/translations/es-help.txt @@ -1,52 +1,52 @@ Instrucciones: - $ curl wttr.in # el clima en su ubicación actual - $ curl wttr.in/muc # el clima en el aeropuerto de Múnich + $ curl wttr.in # El clima en su ubicación actual + $ curl wttr.in/muc # El clima en el aeropuerto de Múnich Tipos de ubicación soportados: - /paris # el nombre de una ciudad - /~Eiffel+tower # el nombre de cualquier sitio famoso - /Москва # el nombre Unicode de cualquier sitio en cualquier idioma - /muc # el código de un aeropuerto (3 letras) - /@stackoverflow.com # el nombre de un dominio web - /94107 # un código de area - /-78.46,106.79 # coordenadas de GPS + /paris # El nombre de una ciudad + /~Eiffel+tower # El nombre de cualquier sitio famoso + /Москва # El nombre en Unicode de cualquier sitio en cualquier idioma + /muc # El código de un aeropuerto (3 letras) + /@stackoverflow.com # El nombre de un dominio web + /94107 # Un código de area + /-78.46,106.79 # Coordenadas de GPS Sitios especiales: - /moon # la fase de la luna (añade ,+US o ,+France para estos paises) - /moon@2016-10-25 # la fase de la luna en una fecha específica (@2016-10-25) + /moon # La fase de la luna (añade ,+US o ,+France para estos paises) + /moon@2016-10-25 # La fase de la luna en una fecha específica (@2016-10-25) Unidades: - ?m # métricas (SI) (el estándar en todos los sitios excepto en EEUU) + ?m # Métricas (SI) (el estándar en todos los sitios excepto en EEUU) ?u # Sistema Unificado de Clasificación del Suelo o USCS (el estándar en EEUU) - ?M # mostrar la velocidad del viento en m/s + ?M # Mostrar la velocidad del viento en m/s Opciones de visualización: - ?0 # solamente el clima actual - ?1 # el clima actual + la previsión de 1 día - ?2 # el clima actual + la previsión de 2 días - ?n # versión corta (solo el día y la noche) - ?q # versión silenciosa (sin el texto de "El tiempo en") - ?Q # versión supersilenciosa (ni "El tiempo en" ni el nombre de la ciudad) - ?T # desactiva las secuencias de terminal (sin colores) + ?0 # Solamente el clima actual + ?1 # El clima actual + la previsión del día siguiente + ?2 # El clima actual + la previsión de los dos días siguientes + ?n # Versión corta (solo día y noche) + ?q # Versión silenciosa (sin el texto de "El tiempo en") + ?Q # Versión supersilenciosa (ni "El tiempo en" ni el nombre de la ciudad) + ?T # Desactiva las secuencias de terminal (sin colores) Opciones de PNG: - /paris.png # genera una imagen PNG - ?p # añade un borde alrededor de la imagen - ?t # transparencia 150 - transparency=... # transparencia de 0 a 255 (255 = sin transparencia) + /paris.png # Genera una imagen PNG + ?p # Añade un borde alrededor de la imagen + ?t # Transparencia = 150 + transparency=... # Transparencia de 0 a 255 (255 = sin transparencia) Las opciones se pueden utilizar conjuntamente: /Paris?0pq /Paris?0pq&lang=fr - /Paris_0pq.png # en PNG las opciones se especifican después del carácter _ - /Rome_0pq_lang=it.png # una larga secuencia de opciones se puede separar por el carácter _ + /Paris_0pq.png # En modo PNG las opciones se especifican después del carácter _ (guión bajo) + /Rome_0pq_lang=it.png # Una larga secuencia de opciones se puede separar por el carácter _ (guión bajo) Ubicación: @@ -61,6 +61,6 @@ Idiomas soportados: URLs especiales: - /:help # muestra esta página - /:bash.function # sugiere una función wttr() en bash - /:translation # muestra información acerca de los traductores + /:help # Muestra esta página + /:bash.function # Muestra una función wttr() sugerida en bash + /:translation # Muestra información acerca de los traductores diff --git a/share/translations/es.txt b/share/translations/es.txt index 177fe1f..7f0a145 100644 --- a/share/translations/es.txt +++ b/share/translations/es.txt @@ -16,7 +16,7 @@ 263: Llovizna ligera irregular: Patchy light drizzle 266: Llovizna ligera: Light drizzle 281: Llovizna helada: Freezing drizzle -284: Llovizna fuertemente helada: Heavy freezing drizzle +284: Llovizna muy helada: Heavy freezing drizzle 293: Lluvia ligera irregular: Patchy light rain 296: Lluvia ligera: Light rain 299: Lluvia moderada ocasional: Moderate rain at times @@ -33,9 +33,9 @@ 332: Nieve moderada: Moderate snow 335: Nieve pesada irregular: Patchy heavy snow 338: Nieve pesada: Heavy snow -350: Gránulos de hielo: Ice pellets +350: Perdigones de hielo: Ice pellets 353: Aguacero ligero: Light rain shower -356: Aguacero moderada o fuerte: Moderate or heavy rain shower +356: Aguacero moderado o fuerte: Moderate or heavy rain shower 359: Aguacero torrencial: Torrential rain shower 362: Aguacero ligero con aguanieve: Light sleet showers 365: Aguacero con aguanieve moderado o fuerte: Moderate or heavy sleet showers From b5d3da52cce40bfc598e5f2b536167d8b514ec11 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Thu, 31 Dec 2020 21:28:01 +0100 Subject: [PATCH 2/5] Add alias conversion for YYZ (#557) --- share/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/share/aliases b/share/aliases index f0955f7..b2adbf1 100644 --- a/share/aliases +++ b/share/aliases @@ -49,3 +49,4 @@ Braga : Braga, Portugal Kashan : ~Kashan,Iran Baku : Baku,Az Rome : Rome, Italia +YYZ : Toronto Pearson Airport From 4e42841c4b0f0874333e9f39b2139499e440fa45 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 1 Jan 2021 18:35:27 +0100 Subject: [PATCH 3/5] Clean we-lang code up --- share/we-lang/we-lang.go | 72 +++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/share/we-lang/we-lang.go b/share/we-lang/we-lang.go index ff9fa05..5aa56d2 100644 --- a/share/we-lang/we-lang.go +++ b/share/we-lang/we-lang.go @@ -548,7 +548,7 @@ func pad(s string, mustLen int) (ret string) { } func formatTemp(c cond) string { - color := func(temp int, explicit_plus bool) string { + color := func(temp int, explicitPlus bool) string { var col = 0 if !config.Inverse { col = 21 @@ -646,11 +646,10 @@ func formatTemp(c cond) string { if config.Imperial { temp = (temp*18 + 320) / 10 } - if explicit_plus { + if explicitPlus { return fmt.Sprintf("\033[38;5;%03dm+%d\033[0m", col, temp) - } else { - return fmt.Sprintf("\033[38;5;%03dm%d\033[0m", col, temp) } + return fmt.Sprintf("\033[38;5;%03dm%d\033[0m", col, temp) } t := c.TempC if t == 0 { @@ -663,17 +662,17 @@ func formatTemp(c cond) string { // } hyphen = ".." - explicit_plus := false + explicitPlus := false if c.FeelsLikeC < t { if c.FeelsLikeC < 0 && t > 0 { - explicit_plus = true + explicitPlus = true } - return pad(fmt.Sprintf("%s%s%s °%s", color(c.FeelsLikeC, false), hyphen, color(t, explicit_plus), unitTemp[config.Imperial]), 15) + return pad(fmt.Sprintf("%s%s%s °%s", color(c.FeelsLikeC, false), hyphen, color(t, explicitPlus), unitTemp[config.Imperial]), 15) } else if c.FeelsLikeC > t { if t < 0 && c.FeelsLikeC > 0 { - explicit_plus = true + explicitPlus = true } - return pad(fmt.Sprintf("%s%s%s °%s", color(t, false), hyphen, color(c.FeelsLikeC, explicit_plus), unitTemp[config.Imperial]), 15) + return pad(fmt.Sprintf("%s%s%s °%s", color(t, false), hyphen, color(c.FeelsLikeC, explicitPlus), unitTemp[config.Imperial]), 15) } return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15) } @@ -735,8 +734,8 @@ func formatWind(c cond) string { // } hyphen = "-" - cWindGustKmph := fmt.Sprintf("%s", color(c.WindGustKmph)) - cWindspeedKmph := fmt.Sprintf("%s", color(c.WindspeedKmph)) + cWindGustKmph := color(c.WindGustKmph) + cWindspeedKmph := color(c.WindspeedKmph) if windInRightUnits(c.WindGustKmph) > windInRightUnits(c.WindspeedKmph) { return pad(fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString), 15) } @@ -770,7 +769,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) { } if config.Inverse { // inverting colors - for i, _ := range icon { + for i := range icon { icon[i] = strings.Replace(icon[i], "38;5;226", "38;5;94", -1) icon[i] = strings.Replace(icon[i], "38;5;250", "38;5;243", -1) icon[i] = strings.Replace(icon[i], "38;5;21", "38;5;18", -1) @@ -787,7 +786,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) { } for runewidth.StringWidth(desc) > 15 { _, size := utf8.DecodeLastRuneInString(desc) - desc = desc[size:len(desc)] + desc = desc[size:] } } else { for runewidth.StringWidth(desc) < 15 { @@ -810,7 +809,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) { } else { if config.RightToLeft { if frstRune, size := utf8.DecodeRuneInString(desc); frstRune != ' ' { - desc = "…" + desc[size:len(desc)] + desc = "…" + desc[size:] for runewidth.StringWidth(desc) < 15 { desc = " " + desc } @@ -955,28 +954,26 @@ func printDay(w weather) (ret []string) { return append(ret, "└──────────────────────────────┴──────────────────────────────┘") + } + + names := "" + if config.RightToLeft { + names = "│" + justifyCenter(trans[3], 29) + "│ " + justifyCenter(trans[2], 16) + + "└──────┬──────┘" + justifyCenter(trans[1], 16) + " │" + justifyCenter(trans[0], 29) + "│" } else { + names = "│" + justifyCenter(trans[0], 29) + "│ " + justifyCenter(trans[1], 16) + + "└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│" + } - names := "" - if config.RightToLeft { - names = "│" + justifyCenter(trans[3], 29) + "│ " + justifyCenter(trans[2], 16) + - "└──────┬──────┘" + justifyCenter(trans[1], 16) + " │" + justifyCenter(trans[0], 29) + "│" - } else { - names = "│" + justifyCenter(trans[0], 29) + "│ " + justifyCenter(trans[1], 16) + - "└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│" - } + ret = append([]string{ + " ┌─────────────┐ ", + "┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐", + names, + "├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤"}, + ret...) - ret = append([]string{ - " ┌─────────────┐ ", - "┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐", - names, - "├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤"}, - ret...) - - return append(ret, - "└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘") - } - return + return append(ret, + "└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘") } func unmarshalLang(body []byte, r *resp) error { @@ -1031,10 +1028,9 @@ func unmarshalLang(body []byte, r *resp) error { var buf bytes.Buffer if err := json.NewEncoder(&buf).Encode(rv); err != nil { return err - } else { - if err = json.NewDecoder(&buf).Decode(r); err != nil { - return err - } + } + if err := json.NewDecoder(&buf).Decode(r); err != nil { + return err } return nil } @@ -1084,7 +1080,7 @@ func getDataFromAPI() (ret resp) { var out bytes.Buffer json.Indent(&out, body, "", " ") out.WriteTo(os.Stderr) - fmt.Println("\n") + fmt.Print("\n\n") } if config.Lang == "" { From 482dffc9a96d82948fa4e45c6a88e851472dd658 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 1 Jan 2021 18:44:05 +0100 Subject: [PATCH 4/5] Use violet for extremely cold temp (#11) --- share/we-lang/we-lang.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/we-lang/we-lang.go b/share/we-lang/we-lang.go index 5aa56d2..614b1e0 100644 --- a/share/we-lang/we-lang.go +++ b/share/we-lang/we-lang.go @@ -551,10 +551,12 @@ func formatTemp(c cond) string { color := func(temp int, explicitPlus bool) string { var col = 0 if !config.Inverse { - col = 21 + // Extemely cold temperature must be shown with violet + // because dark blue is too dark + col = 165 switch temp { case -15, -14, -13: - col = 27 + col = 171 case -12, -11, -10: col = 33 case -9, -8, -7: From ab756f1134e40cce582ee7d6d2a507abd3ff2b5c Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 1 Jan 2021 23:20:47 +0100 Subject: [PATCH 5/5] Check for 'United States of America' (#474) --- lib/wttr_srv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wttr_srv.py b/lib/wttr_srv.py index f8a7697..327eeec 100644 --- a/lib/wttr_srv.py +++ b/lib/wttr_srv.py @@ -301,7 +301,7 @@ def parse_request(location, request, query, fast_mode=False): location, override_location_name, full_address, country, query_source_location, hemisphere = \ location_processing(parsed_query["location"], parsed_query["ip_addr"]) - us_ip = query_source_location[1] == 'United States' \ + us_ip = query_source_location[1] in ["United States", "United States of America"] \ and 'slack' not in parsed_query['user_agent'] query = parse_query.metric_or_imperial(query, lang, us_ip=us_ip)