Skip to content

Commit

Permalink
Factor our local string to constant defined in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusroemer committed Oct 2, 2024
1 parent 3493c70 commit 5834b93
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion website/src/components/IndexPage/OrganismCard.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import type { OrganismStatistics } from './getOrganismStatistics';
import { routes } from '../../routes/routes';
import { DEFAULT_LOCALE } from '../../settings';
interface Props {
key: string;
Expand All @@ -12,7 +13,7 @@ interface Props {
const { key, image, displayName, organismStatistics, numberDaysAgoStatistics } = Astro.props;
const formatNumber = (num: number) => new Intl.NumberFormat('en-US').format(num);
const formatNumber = (num: number) => new Intl.NumberFormat(DEFAULT_LOCALE).format(num);
---

<a
Expand Down
8 changes: 4 additions & 4 deletions website/src/components/SearchPage/SearchFullUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Table, type TableSequenceData } from './Table';
import useQueryAsState from './useQueryAsState.js';
import { getLapisUrl } from '../../config.ts';
import { lapisClientHooks } from '../../services/serviceHooks.ts';
import { pageSize } from '../../settings';
import { DEFAULT_LOCALE, pageSize } from '../../settings';
import type { Group } from '../../types/backend.ts';
import {
type MetadataFilter,
Expand Down Expand Up @@ -305,10 +305,10 @@ export const InnerSearchFullUI = ({
<div className='mt-auto'>
Search returned{' '}
{totalSequences !== undefined
? totalSequences.toLocaleString('en-US')
? totalSequences.toLocaleString(DEFAULT_LOCALE)
: oldCount !== null
? oldCount.toLocaleString('en-US')
: initialCount.toLocaleString('en-US')}{' '}
? oldCount.toLocaleString(DEFAULT_LOCALE)
: initialCount.toLocaleString(DEFAULT_LOCALE)}{' '}
sequence
{totalSequences === 1 ? '' : 's'}
{detailsHook.isLoading ||
Expand Down
3 changes: 2 additions & 1 deletion website/src/components/SearchPage/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { FC, ReactElement } from 'react';
import { Tooltip } from 'react-tooltip';

import { routes } from '../../routes/routes.ts';
import { DEFAULT_LOCALE } from '../../settings.ts';
import type { Schema } from '../../types/config.ts';
import type { Metadatum, OrderBy } from '../../types/lapis.ts';
import MdiTriangle from '~icons/mdi/triangle';
Expand All @@ -19,7 +20,7 @@ function formatField(value: any, maxLength: number, type: string): string {
if (type === 'timestamp') {
return new Date(value * 1000).toISOString().slice(0, 10);
}
return value.toLocaleString('en-US');
return value.toLocaleString(DEFAULT_LOCALE);
} else if (typeof value === 'boolean') {
return value ? 'True' : 'False';
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useMemo, useState, useRef, forwardRef } from 'react';
import { TextField } from './TextField.tsx';
import { getClientLogger } from '../../../clientLogger.ts';
import { lapisClientHooks } from '../../../services/serviceHooks.ts';
import { DEFAULT_LOCALE } from '../../../settings.ts';
import { type GroupedMetadataFilter, type MetadataFilter, type SetAFieldValue } from '../../../types/config.ts';

type AutoCompleteFieldProps = {
Expand Down Expand Up @@ -157,7 +158,7 @@ export const AutoCompleteField = ({
{option.option}
</span>
<span className='inline-block ml-1'>
({option.count.toLocaleString('en-US')})
({option.count.toLocaleString(DEFAULT_LOCALE)})
</span>
{selected && (
<span
Expand Down
2 changes: 2 additions & 0 deletions website/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export const DATA_USE_TERMS_FIELD = 'dataUseTerms';
export const VERSION_COMMENT_FIELD = 'versionComment';

export const metadataDefaultDownloadDataFormat = 'tsv';

export const DEFAULT_LOCALE = 'en-US';

0 comments on commit 5834b93

Please sign in to comment.