I am new to web development and for me I was stuck in Java for a long time and never really liked it and thought all languages would be the same.
Then I worked with python and I was creating code without having to look at an API or manual for the first time. After this I went looking for my favorite languages. C, PHP, Mysql, mongodb, Javascript and all its frameworks, and then I ran into Ruby.
So from a intermediate to approaching advanced programmer I would say to generalize at first because you never know what you might like until you try it. Ruby is the language that I find fun yet challenging. Python was too easy while java was challenging but was never fun to me. Find your sweet spot.
I dont plan on stopping my language learning spread any time soon.
With my experience learning more languages will naturally arise with the need to implement certain features. (most seasoned programmers tend to know multiple languages as a result of circumstance ). When a client requests features that tend towards a SPA and you are say, a PHP developer, then the need to learn Javascript will arise.
Languages come and go. Many development companies don't rely on just JS or just PHP or just Ruby. They generally need a combination of many for different projects. They may be supporting legacy code; they may work for different clients; they may just want to keep their options open.
One of my last jobs, while there, I wrote in C#, PHP, JS and Python.
It's good to be great in a language - PHP has always been my strongest. But don't lock yourself into 1. Get good at your primary language, spending a few years building and focusing on it - then, expand your horizons into other languages. It'll make you more marketable to companies and if problems arise, you can help solve them on multiple fronts.
I think these two aspects are not conflict. Learning and mastering is different. Learning more languages helps in realizing my limitations in using my current languages and I can find direction towards a better situation. Meanwhile mastering a languages requires lots of practices.