I need to detect OS language using javascript so I can view my page depending on the language.
I know that we can detect the browser language but that is not enough
You can use the user agent. However, it can be spoofed easily, it is not guaranteed to contain language information, and navigator.language and navigator.browserLanguage will probably be more reliable.
navigator.language
navigator.browserLanguage