Skip to content

Instantly share code, notes, and snippets.

export default function getBrowserLocale(options = {}) {
const defaultOptions = { countryCodeOnly: false }
const opt = { ...defaultOptions, ...options }
const navigatorLocale =
navigator.languages !== undefined
? navigator.languages[0]
: navigator.language
@lordlycastle
lordlycastle / BaseSingleton.cs
Last active May 7, 2024 14:41
Abstract singleton class for Unity.
using System.Linq;
using UnityEngine;
/// <summary>
/// Abstract singleton class for Unity. Updated with possible errors:
/// - Doesn't create a new singleton if it is in scene.
/// - Singleton has an initialize method which is called on creation, finding one from scene, or awake. Which makes sure initialization always happen before using it.
/// - It doesn't create a new single if you try to access it OnDestroy (e.g. game quit). Returns null instead.
/// </summary>
/// <typeparam name="TSingleton">Type of singleton. (Same as class inheriting from it.)</typeparam>
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//