This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
namespace myApp | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
double value = 123456.78d; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatWithThousandsSeparator(num) { | |
let numAsString = num.toString(); | |
let characters = numAsString.split("").reverse(); | |
let parts = []; | |
for (let i = 0; i < characters.length; i += 3) { | |
let part = characters.slice(i, i + 3).reverse().join(""); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { useIntl } from "react-intl"; | |
import { supportedLangs } from "./i18n"; | |
export default function LangSwitcher() { | |
const { locale: lang } = useIntl(); | |
return ( | |
<div className="navbar-item has-dropdown is-hoverable"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const defaultLang = "en"; | |
export const supportedLangs = { | |
en: "English", | |
ar: "Arabic (عربي)", | |
}; | |
export function determineUserLang(acceptedLangs, path = null) { | |
// check url for /en/foo where en is a supported language code | |
if (path !== null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import express from "express"; | |
import { StaticRouter } from "react-router-dom"; | |
import { renderToString } from "react-dom/server"; | |
import App from "./common/App"; | |
import render from "./server/render"; | |
import { determineUserLang } from "./common/i18n"; | |
const server = express(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { hydrate } from "react-dom"; | |
import { BrowserRouter } from "react-router-dom"; | |
import App from "./common/App"; | |
import { determineUserLang } from "./common/i18n"; | |
const lang = determineUserLang( | |
navigator.languages || [], | |
window.location.pathname, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { IntlProvider } from "react-intl"; | |
import { Route, Switch } from "react-router-dom"; | |
import Navbar from "./Navbar"; | |
import Home from "./pages/Home"; | |
import { defaultLang } from "./i18n"; | |
import messages from "./i18n/messages"; | |
import GameIndex from "./pages/GameIndex"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { hydrate } from "react-dom"; | |
import { BrowserRouter } from "react-router-dom"; | |
import App from "./common/App"; | |
import { determineUserLang } from "./common/i18n"; | |
const lang = determineUserLang(navigator.languages || []); | |
hydrate( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import express from "express"; | |
import { StaticRouter } from "react-router-dom"; | |
import { renderToString } from "react-dom/server"; | |
import App from "./common/App"; | |
import render from "./server/render"; | |
import { determineUserLang } from "./common/i18n"; | |
const server = express(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const defaultLang = "en"; | |
export const supportedLangs = { | |
en: "English", | |
ar: "Arabic (عربي)", | |
}; | |
export function determineUserLang(acceptedLangs) { | |
const acceptedLangCodes = acceptedLangs.map(stripCountry); |