A way to get Obsidian’s currently set language?

I’m bilingual and switch Obsidian languages quite often. We do have different number formats in UK and Germany, so I’d like to use JS .toLocaleString(undefined, {maximumFractionDigits: 1}) with the language Obsidian is set to, not my OS’s language.

Unfortunately, using undefined decides to use German (de-DE), and navigator.language also returns de when Obsidian runs in English.

It makes a difference seeing 4,096.0 vs 4.096,0

Any insights on how to get that language setting, preferably in the en-GB (or en-UK or de-DE or de-AT …) format?

I’m not sure what the “right way” is, but one possibility is to use moment.locale(). It’ll return whatever language obsidian is set to.

1 Like

Cheers, that’s perfect, since I use moment.js anyway for date calculations! Much appreciated.

1 Like

For whatever odd reason, this now seems to be broken in 0.12.4, see New with 0.12.4: Moment.locale() sticks at "en" even when I switch Obsidian to another language.