There is an official template that demonstrates how to do it:
editor.construct.net
To auto-detect language on startup you can use Browser.language expression. lowercase(left(Browser.language,2)) will give you a two-letter language code, for example "en" or "de".
Also, for static texts you can automatically grab translations from the array. Here is how I do it - I add all static text object into a family "LanguageTexts". Define "tag" instance variable on the family. On start of layout I loop through all LanguageTexts using "For each" loop, lookup translation in the table with each tag and update the texts.