Repository: syncthing/syncthing
File: gui/default/syncthing/core/localeService.js (JavaScript)

Code before:
                } else {
                    readBrowserLocales().success(function (langs) {
                        // Find the first language in the list provided by the user's browser
                        // that is a prefix of a language we have available. That is, "en"
                        // sent by the browser will match "en" or "en-US", while "zh-TW" will
                        // match only "zh-TW" and not "zh" or "zh-CN".

                        var i,
                            browserLang,
                            matching,
                            locale = _defaultLocale;

                        for (i = 0; i < langs.length; i++) {
                            browserLang = langs[i];

                            if (browserLang.length < 2) {
                                continue;
                            }

                            matching = _availableLocales.filter(function (possibleLang) {
                                // The langs returned by the /rest/langs call will be in lower
                                // case. We compare to the lowercase version of the language
                                // code we have as well.
                                possibleLang = possibleLang.toLowerCase();
                                if (possibleLang.indexOf(browserLang) !== 0) {
                                    // Prefix does not match.
                                    return false;
                                }
                                if (possibleLang.length > browserLang.length) {
                                    // Must match up to the next hyphen separator.
                                    return possibleLang[browserLang.length] === '-';
                                }
                                // Same length, exact match.
                                return true;
                            });

                            if (matching.length >= 1) {
                                locale = matching[0];
                                break;
                            }
                        }
                        // Fallback if nothing matched
                        useLocale(locale);
                    });
                }
            }

            function useLocale(language, save2Storage) {
                if (language) {
                    $translate.use(language).then(function () {
                        document.documentElement.setAttribute("lang", language);

Review comment (suggestion):
```suggestion
                                    // Prefix does not match
```
Please let's not get started on this.  It's just code comments and for such short notes, we really don't need to pretend it's part of a prose text.  Please stick to the established style in this point.

Code after:
                } else {
                    readBrowserLocales().success(function (langs) {
                        // Find the first language in the list provided by the user's browser
                        // that is a prefix of a language we have available. That is, "en"
                        // sent by the browser will match "en" or "en-US", while "zh-TW" will
                        // match only "zh-TW" and not "zh" or "zh-CN".

                        var i,
                            browserLang,
                            matching,
                            locale = _defaultLocale; // Fallback if nothing matched

                        for (i = 0; i < langs.length; i++) {
                            browserLang = langs[i];

                            if (browserLang.length < 2) {
                                continue;
                            }

                            matching = _availableLocales.filter(function (possibleLang) {
                                // The langs returned by the /svc/langs call will be in lower
                                // case. We compare to the lowercase version of the language
                                // code we have as well.
                                possibleLang = possibleLang.toLowerCase();
                                if (possibleLang.indexOf(browserLang) !== 0) {
                                    // Prefix does not match
                                    return false;
                                }
                                if (possibleLang.length > browserLang.length) {
                                    // Must match up to the next hyphen separator
                                    return possibleLang[browserLang.length] === '-';
                                }
                                // Same length, exact match
                                return true;
                            });

                            if (matching.length >= 1) {
                                locale = matching[0];
                                break;
                            }
                        }
                        useLocale(locale);
                    });
                }
            }

            function useLocale(language, save2Storage) {
                if (language) {
                    $translate.use(language).then(function () {
                        document.documentElement.setAttribute("lang", language);
                        if (save2Storage && _localStorage)