import type { ReactNode } from 'react' export type Lang = 'ru' | 'en' /** Both languages side by side; html[data-lang] decides which one is shown, so there is no flash and no state. */ export function Bi({ ru, en }: Readonly<{ ru: ReactNode; en: ReactNode }>) { return ( <> {ru} {en} ) } const pluralRu = new Intl.PluralRules('ru') const pluralEn = new Intl.PluralRules('en') /** "21 проект" / "21 project": Russian has three forms (1 / 2-4 / 5+), English two. */ export function count(n: number, ru: [string, string, string], en: [string, string]) { const r = pluralRu.select(n) return { ru: `${n} ${r === 'one' ? ru[0] : r === 'few' ? ru[1] : ru[2]}`, en: `${n} ${pluralEn.select(n) === 'one' ? en[0] : en[1]}`, } } export const monthYear = (iso: string | undefined, lang: Lang) => iso ? new Date(iso).toLocaleDateString(lang, { month: 'short', year: 'numeric' }) : '' // Where the other pages of shanaty.ru live. Empty in the production build (root-relative links); the default is // for builds that run elsewhere (dev, GitHub Pages), where relative links would point at the wrong site. export const SITE = process.env.NEXT_PUBLIC_SITE_ORIGIN ?? 'https://shanaty.ru'