Help with !weather translation

Asked Apr 6, 2022·5 replies·Last activity 4 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hi
I'm trying to build a weather command translating the parts from English to Spanish, for that I based on this post /t/weather-to-another-language/1534638544805433344
So far so good, but I wanted to go a little further and also translate the variables that the command throws, but I ran into the problem that I do not reach the characters ... my question is if there is a way to use a pastebin to replace this part of the command in specific and so I can translate it in its entirety. Note: I had to omit the "at" part in the wind forecast because it gave error since it uses the word "temperatura" and modifies the "at" inside the word, I do not know if there is a way to correct this too.

$(eval '$(weather $(query))'.replace('Weather for', 'El tiempo para').replace('Conditions are', 'Las condiciones meteorológicas son').replace('with a temperature of', 'con una temperatura de').replace('The wind is blowing from the', 'La dirección del viento es').replace('and the current humidity is', 'y la humedad actual es del').replace('No location provided', 'Escribe tu ciudad/país en Inglés.'))

.replace('Fair', 'buen tiempo').replace('Snow Shower', 'nevadas').replace('Mostly', 'mayormente').replace('Clear', 'cielo despejado').replace('Cloudy', 'nublado').replace('Partly', 'parcialmente').replace('Sunny', 'soleado').replace('rain', 'lluvioso').replace('Wind', 'ventoso'))

I thank you in advance, any idea is welcome, my head exploded trying, I am noob in all this command programming, but little by little I am learning thanks to this site and to all those who share their knowledge.

screenshot.69.jpg

5 replies

I have the same issue and i'm trying to solve it

Hey @Keen Rabbit and @Golden Beetle!

It seems to me your issue is mostly the lack of space to write the code, right?

To answer your question, yes, you can use Pastebin to expand your code, here's how to do it:

$(eval w='$(weather $(query))'; $(urlfetch json https://pastebin.com/raw/XXXXXXXXX))

And in your paste:

w.replace().replace().replace().[...].replace()

Since you'll have more room to write the code, I recommend using regex in the replace to match expressions regardless of the capitalization:

.replace(/Text tO replAce/i, 'replacing text')
Keen Rabbit said:
.replace('Snow Shower', 'nevadas').replace('Mostly', 'mayormente').replace('Clear', 'cielo despejado').replace('Cloudy', 'nublado').replace('Partly', 'parcialmente').replace('Sunny', 'soleado').replace('rain', 'lluvioso').replace('Wind', 'ventoso'))

Thank you a lot. This solved the issue for me. The only thing not working properly as intended for me is the "at" that leonxnez said. It gives a problem if translated. Similar to that also "and the" before "current humidity" and "is" after that "current humidity". When i'm trying to translate those words it turns into a bug to me.

However is already cool like this, thank you a lot.

Thank you so much Emily!!! it worked perfectly! I really appreciate you helping us to solve these problems that we are facing when we have ideas to improve the user experience within the streams. :purple_heart:

I'm not sure I understand, do you still have an issue? If so, please post your code here.

Didn't find your answer? The community is on Discord.

Ask on Discord