Skip to content

Commit

Permalink
Merge pull request #1915 from sportstimes/task/site-selector-locale-all
Browse files Browse the repository at this point in the history
Task/site selector locale all
  • Loading branch information
ay8s authored Jan 5, 2025
2 parents bb0a0c9 + 4b4b333 commit 7e107ff
Show file tree
Hide file tree
Showing 32 changed files with 6,784 additions and 6,736 deletions.
503 changes: 252 additions & 251 deletions locales/ar/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/cs/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/da/localization.json

Large diffs are not rendered by default.

503 changes: 252 additions & 251 deletions locales/de/localization.json

Large diffs are not rendered by default.

403 changes: 203 additions & 200 deletions locales/el/localization.json

Large diffs are not rendered by default.

544 changes: 272 additions & 272 deletions locales/en/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/es/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/fi/localization.json

Large diffs are not rendered by default.

405 changes: 203 additions & 202 deletions locales/fr/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/hr/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/hu/localization.json

Large diffs are not rendered by default.

399 changes: 201 additions & 198 deletions locales/id/localization.json

Large diffs are not rendered by default.

403 changes: 203 additions & 200 deletions locales/it/localization.json

Large diffs are not rendered by default.

503 changes: 253 additions & 250 deletions locales/ja/localization.json

Large diffs are not rendered by default.

503 changes: 253 additions & 250 deletions locales/lv/localization.json

Large diffs are not rendered by default.

402 changes: 201 additions & 201 deletions locales/nl/localization.json

Large diffs are not rendered by default.

405 changes: 203 additions & 202 deletions locales/no/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/pl/localization.json

Large diffs are not rendered by default.

398 changes: 201 additions & 197 deletions locales/ro/localization.json

Large diffs are not rendered by default.

397 changes: 199 additions & 198 deletions locales/ru/localization.json

Large diffs are not rendered by default.

403 changes: 203 additions & 200 deletions locales/sk/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/sl/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/sq/localization.json

Large diffs are not rendered by default.

503 changes: 253 additions & 250 deletions locales/sr/localization.json

Large diffs are not rendered by default.

401 changes: 201 additions & 200 deletions locales/sv/localization.json

Large diffs are not rendered by default.

503 changes: 253 additions & 250 deletions locales/ta/localization.json

Large diffs are not rendered by default.

397 changes: 199 additions & 198 deletions locales/tr/localization.json

Large diffs are not rendered by default.

397 changes: 199 additions & 198 deletions locales/uk/localization.json

Large diffs are not rendered by default.

403 changes: 203 additions & 200 deletions locales/zh-HK/localization.json

Large diffs are not rendered by default.

403 changes: 203 additions & 200 deletions locales/zh/localization.json

Large diffs are not rendered by default.

605 changes: 298 additions & 307 deletions src/app/[locale]/generate/form.tsx

Large diffs are not rendered by default.

128 changes: 67 additions & 61 deletions src/components/SiteSelector/SiteSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,81 @@
"use client"
'use client';

import React, {Component} from "react";
import {useTranslations} from 'next-intl';
import { useRouter, useParams} from 'next/navigation'
import {usePlausible} from "next-plausible";
import React, { Component } from 'react';
import { useRouter, useParams } from 'next/navigation';
import { usePlausible } from 'next-plausible';
import { useLocale, useTranslations } from 'next-intl';

interface SiteConfig {
name: string;
siteKey: string;
url: string;
calenderCDN: string;
supportsEmailReminders: boolean;
supportsWebPush: boolean;
name: string;
siteKey: string;
url: string;
calenderCDN: string;
supportsEmailReminders: boolean;
supportsWebPush: boolean;
}

const SiteSelector: FunctionComponent = ({}) => {
const plausible = usePlausible();
const router = useRouter()
const t = useTranslations('All');
const plausible = usePlausible();
const router = useRouter();
const t = useTranslations('All');
const locale = useLocale();

const sitesConfig = require(`/_db/sites.json`);
const sites = sitesConfig.sites;

const config = require(`/_db/${process.env.NEXT_PUBLIC_SITE_KEY}/config.json`);

// Picker Items
const siteItems: React.ReactElement[] = [];
let currentValue = "";

sitesConfig.sites.forEach(function (site: SiteConfig, index: number) {
if(site.siteKey == config.siteKey){
currentValue = site.url;
}

siteItems.push(
<option value={site.url} key={site.siteKey}>
{site.name}
</option>
);
});
const sitesConfig = require(`/_db/sites.json`);
const sites = sitesConfig.sites;

const onChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
plausible("Changed Site", {
props: {
site: event.target.value
}
});

router.push(event.target.value, event.target.value);
};
const config = require(
`/_db/${process.env.NEXT_PUBLIC_SITE_KEY}/config.json`,
);


// Picker Items
const siteItems: React.ReactElement[] = [];
let currentValue = '';

return (
<div>
<label htmlFor="site" className="sr-only">
Select Site
</label>
<select
aria-label="Motorsport"
name="site"
onChange={onChange}
value={currentValue}
className="text-gray-900 pl-2 pr-8 py-0 text-base
sitesConfig.sites.forEach(function (site: SiteConfig, index: number) {
if (site.siteKey == config.siteKey) {
currentValue = site.url;
}

let url = site.url;
if (locale != 'en') {
url = `${site.url}/${locale}`;
}

siteItems.push(
<option value={url} key={site.siteKey}>
{site.name}
</option>,
);
});

const onChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
plausible('Changed Site', {
props: {
site: event.target.value,
},
});

router.push(event.target.value, event.target.value);
};

return (
<div>
<label htmlFor="site" className="sr-only">
Select Site
</label>
<select
aria-label="Motorsport"
name="site"
onChange={onChange}
value={currentValue}
className="text-gray-900 pl-2 pr-8 py-0 text-base
border-gray-300 focus:outline-none focus:ring-indigo-500
focus:border-indigo-500 sm:text-sm rounded-md"
>
{siteItems}
</select>
</div>
);
}
>
{siteItems}
</select>
</div>
);
};

export default SiteSelector;

0 comments on commit 7e107ff

Please sign in to comment.