Skip to content

Commit c815d86

Browse files
author
Saket Hatwar
committed
Additional Translations
1 parent 3fc2147 commit c815d86

File tree

10 files changed

+189
-43
lines changed

10 files changed

+189
-43
lines changed

modules/dataquery/jsx/components/filterableselectgroup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Select, {SingleValue} from 'react-select';
2+
import {useTranslation} from 'react-i18next';
23

34
type SelectOption = {
45
label: string,
@@ -27,8 +28,9 @@ function FilterableSelectGroup(props: {
2728
groups: object,
2829
mapGroupName?: (module: string) => string,
2930
}) {
31+
const {t} = useTranslation('dataquery');
3032
const groups: SelectGroup[] = [];
31-
const placeholder = props.placeholder || 'Select a category';
33+
const placeholder = props.placeholder || t('Select a category');
3234
for (const [module, subcategories]
3335
of Object.entries(props.groups)) {
3436
const options: SelectOption[] = [];

modules/dataquery/jsx/definefields.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ function QueryField(props: {
9494

9595
if (props.selected) {
9696
visits = <div onClick={(e) => e.stopPropagation()}>
97-
<h4>{t('Visits', {ns: 'loris'})}</h4>
97+
<h4>{t('Visits')}</h4>
9898
<Select options={selectOptions.map((visit: string): VisitOption => {
9999
return {value: visit, label: visit};
100100
})
101101
}
102102
isMulti
103103
onChange={selected}
104-
placeholder={t('Select Visits', {ns: 'loris'})}
104+
placeholder={t('Select Visits', {ns: 'dataquery'})}
105105
value={selectedVisits.map( (visit: string): VisitOption => {
106106
return {value: visit, label: visit};
107107
})
@@ -199,6 +199,7 @@ function DefineFields(props: {
199199
visits: string[]
200200
) => void,
201201
}) {
202+
const {t} = useTranslation('dataquery');
202203
const [activeFilter, setActiveFilter] = useState('');
203204
const [syncVisits, setSyncVisits] = useState<boolean>(false);
204205
const [zoomTo, setZoomTo] = useState<string|null>(null);
@@ -339,11 +340,12 @@ function DefineFields(props: {
339340
return {value: el, label: el};
340341
});
341342
defaultVisits = <div style={{paddingBottom: '1em', display: 'flex'}}>
342-
<h4 style={{paddingRight: '1ex'}}>Default Visits</h4>
343+
<h4 style={{paddingRight: '1ex'}}>{t('Default Visits',
344+
{ns: 'dataquery'})}</h4>
343345
<Select options={allVisits}
344346
isMulti
345347
onChange={props.onChangeDefaultVisits}
346-
placeholder='Select Visits'
348+
placeholder={t('Select Visits', {ns: 'dataquery'})}
347349
menuPortalTarget={document.body}
348350
styles={
349351
{menuPortal:
@@ -360,20 +362,21 @@ function DefineFields(props: {
360362
closeMenuOnSelect={false}
361363
/>
362364
<div>
363-
<CheckboxElement label='Sync with selected fields'
364-
name="syncVisits"
365-
value={syncVisits}
366-
onUserInput={
367-
(name: string, value: boolean) => setSyncVisits(value)
368-
} />
365+
<CheckboxElement label={t('Sync with selected fields',
366+
{ns: 'dataquery'})}
367+
name="syncVisits"
368+
value={syncVisits}
369+
onUserInput={
370+
(name: string, value: boolean) => setSyncVisits(value)
371+
} />
369372
</div>
370373
</div>;
371374
}
372375

373376
fieldList = (<div>
374377
<div style={{display: 'flex', flexWrap: 'wrap',
375378
justifyContent: 'space-between'}}>
376-
<h2>{cname} fields</h2>
379+
<h2>{cname} {t('fields')}</h2>
377380
<div style={{marginTop: '1em',
378381
display: 'flex',
379382
flexWrap: 'nowrap',
@@ -384,7 +387,7 @@ function DefineFields(props: {
384387
<input onChange={setFilter}
385388
className='form-control'
386389
type="text"
387-
placeholder="Filter within category"
390+
placeholder={t('Filter within category', {ns: 'dataquery'})}
388391
aria-describedby="input-filter-addon"
389392
value={activeFilter} />
390393
<span className="input-group-addon">
@@ -399,11 +402,11 @@ function DefineFields(props: {
399402
}}>
400403
<button type="button" className="btn btn-primary"
401404
onClick={addAll}>
402-
Add all
405+
{t('Add all', {ns: 'dataquery'})}
403406
</button>
404407
<button type="button" className="btn btn-primary"
405408
onClick={removeAll}>
406-
Remove all
409+
{t('Remove all', {ns: 'dataquery'})}
407410
</button>
408411
</div>
409412
</div>
@@ -416,7 +419,7 @@ function DefineFields(props: {
416419
<div>
417420
<div style={{display: 'flex', flexWrap: 'nowrap'}}>
418421
<div style={{width: '80vw', padding: '1em'}}>
419-
<h1>Available Fields</h1>
422+
<h1>{t('Available Fields', {ns: 'dataquery'})}</h1>
420423
<FilterableSelectGroup groups={props.allCategories.categories}
421424
mapGroupName={(key) => props.allCategories.modules[key]}
422425
onChange={props.onCategoryChange}
@@ -438,11 +441,11 @@ function DefineFields(props: {
438441
alignItems: 'flex-end',
439442
marginBottom: '1em',
440443
}}>
441-
<h2>Selected Fields</h2>
444+
<h2>{t('Selected Fields', {ns: 'dataquery'})}</h2>
442445
<div>
443446
<button type="button" className="btn btn-primary"
444447
style={{marginBottom: 7}}
445-
onClick={props.onClearAll}>Clear</button>
448+
onClick={props.onClearAll}>{t('Clear')}</button>
446449
</div>
447450
</div>
448451
<SelectedFieldList

modules/dataquery/jsx/definefilters.addfiltermodal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function AddFilterModal(props: {
126126
setSelectedVisits(null);
127127
}
128128
}}
129-
placeholder="Select a field" />;
129+
placeholder={t('Select a field', {ns: 'dataquery'})} />;
130130
}
131131

132132
if (fieldDictionary) {

modules/dataquery/jsx/hooks/usebreadcrumbs.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {useEffect} from 'react';
2+
import {useTranslation} from 'react-i18next';
23
import Breadcrumbs from 'jsx/Breadcrumbs';
34

45
// Declared in smarty main.tpl
@@ -15,11 +16,12 @@ function useBreadcrumbs(
1516
activeTab: string,
1617
setActiveTab: (newtab: string) => void
1718
) {
19+
const {t} = useTranslation('dataquery');
1820
// update breadcrumbs breadcrumbs
1921
useEffect(() => {
2022
const breadcrumbs = [
2123
{
22-
text: 'Data Query Tool (Beta)',
24+
text: t('Data Query Tool (Beta)', {ns: 'dataquery'}),
2325
/**
2426
* OnClick handler for the main breadcrumb
2527
*
@@ -36,7 +38,7 @@ function useBreadcrumbs(
3638
|| activeTab == 'DefineFilters'
3739
|| activeTab == 'ViewData') {
3840
breadcrumbs.push({
39-
text: 'Define Fields',
41+
text: t('Define Fields', {ns: 'dataquery'}),
4042
/**
4143
* OnClick handler for the define fields breadcrumb
4244
*
@@ -52,7 +54,7 @@ function useBreadcrumbs(
5254
if (activeTab == 'DefineFilters'
5355
|| activeTab == 'ViewData') {
5456
breadcrumbs.push({
55-
text: 'Define Filters',
57+
text: t('Define Filters', {ns: 'dataquery'}),
5658
/**
5759
* OnClick handler for the define filters breadcrumb
5860
*
@@ -68,7 +70,7 @@ function useBreadcrumbs(
6870

6971
if (activeTab == 'ViewData') {
7072
breadcrumbs.push({
71-
text: 'View Data',
73+
text: t('View Data', {ns: 'dataquery'}),
7274
/**
7375
* OnClick handler for the View Data breadcrumb
7476
*
@@ -90,7 +92,7 @@ function useBreadcrumbs(
9092
/>,
9193
);
9294
}
93-
}, [activeTab]);
95+
}, [activeTab, t]);
9496
}
9597

9698
export default useBreadcrumbs;

modules/dataquery/jsx/hooks/usedatadictionary.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {useState, useEffect} from 'react';
2+
import {useTranslation} from 'react-i18next';
23

34
import {ModuleDictionary, FullDictionary} from '../types';
45

@@ -23,14 +24,15 @@ export type CategoriesAPIReturn = {
2324
*/
2425
function useCategories(): CategoriesAPIReturn|null {
2526
const [categories, setCategories] = useState(null);
27+
const {t} = useTranslation('dataquery');
2628
useEffect(() => {
2729
if (categories !== null) {
2830
return;
2931
}
3032
fetch('/dictionary/categories', {credentials: 'same-origin'})
3133
.then((resp) => {
3234
if (!resp.ok) {
33-
throw new Error('Invalid response');
35+
throw new Error(t('Invalid response', {ns: 'dataquery'}));
3436
}
3537
return resp.json();
3638
}).then((result) => {
@@ -59,7 +61,7 @@ function useDataDictionary(): DataDictionaryReturnType {
5961
// typescript says the key is always defined when we try and check if
6062
// it's set, need to figure out the correct way to do that, for now just use any
6163
const [pendingModules, setPendingModules] = useState<any>({});
62-
64+
const {t} = useTranslation('dataquery');
6365
/**
6466
* Fetch a module's dictionary and cache it into fulldictionary.
6567
*
@@ -80,7 +82,7 @@ function useDataDictionary(): DataDictionaryReturnType {
8082
{credentials: 'same-origin'}
8183
).then((resp) => {
8284
if (!resp.ok) {
83-
throw new Error('Invalid response');
85+
throw new Error(t('Invalid response', {ns: 'dataquery'}));
8486
}
8587
return resp.json();
8688
}).then((result) => {

modules/dataquery/jsx/viewdata.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ function ViewData(props: {
319319
onRun: () => void
320320
fulldictionary: FullDictionary,
321321
}) {
322+
const {t} = useTranslation('dataquery');
322323
const [visitOrganization, setVisitOrganization]
323324
= useState<VisitOrgType>('inline');
324325
const [headerDisplay, setHeaderDisplay]
@@ -344,7 +345,7 @@ function ViewData(props: {
344345
} else {
345346
switch (organizedData['status']) {
346347
case null:
347-
return queryTable = <h2>Query not yet run</h2>;
348+
return queryTable = <h2>{t('Query not yet run')}</h2>;
348349
case 'headers':
349350
queryTable = <ProgressBar
350351
type='headers'
@@ -360,7 +361,7 @@ function ViewData(props: {
360361
case 'done':
361362
try {
362363
queryTable = <DataTable
363-
rowNumLabel="Row Number"
364+
rowNumLabel={t('Row Number')}
364365
fields={organizedData.headers.map(
365366
(val: string) => {
366367
return {show: true, label: val};
@@ -407,7 +408,7 @@ function ViewData(props: {
407408
<CheckboxElement
408409
name="emptyvisits"
409410
value={emptyVisits}
410-
label="Display empty visits?"
411+
label={t('Display empty visits?', {ns: 'dataquery'})}
411412
onUserInput={
412413
(name: string, value: boolean) =>
413414
setEmptyVisits(value)
@@ -418,9 +419,9 @@ function ViewData(props: {
418419
<SelectElement
419420
name='headerdisplay'
420421
options={{
421-
'fieldname': 'Field Name',
422-
'fielddesc': 'Field Description',
423-
'fieldnamedesc': 'Field Name: Field Description',
422+
'fieldname': t('Field Name'),
423+
'fielddesc': t('Field Description'),
424+
'fieldnamedesc': t('Field Name: Field Description'),
424425
}}
425426
label='Header Display Format'
426427
value={headerDisplay}
@@ -435,12 +436,12 @@ function ViewData(props: {
435436
<SelectElement
436437
name='visitorganization'
437438
options={{
438-
'crosssection': 'Rows (Cross-sectional)',
439-
'longitudinal': 'Columns (Longitudinal)',
440-
'inline': 'Inline values (no download)',
441-
'raw': 'Raw JSON (debugging only)',
439+
'crosssection': t('Rows (Cross-sectional)', {ns: 'dataquery'}),
440+
'longitudinal': t('Columns (Longitudinal)', {ns: 'dataquery'}),
441+
'inline': t('Inline values (no download)', {ns: 'dataquery'}),
442+
'raw': t('Raw JSON (debugging only)', {ns: 'dataquery'}),
442443
}}
443-
label='Display visits as'
444+
label={t('Display visits as', {ns: 'dataquery'})}
444445
value={visitOrganization}
445446
multiple={false}
446447
emptyOption={false}
@@ -453,10 +454,10 @@ function ViewData(props: {
453454
<SelectElement
454455
name='enumdisplay'
455456
options={{
456-
'labels': 'Labels',
457-
'values': 'Values',
457+
'labels': t('Labels', {ns: 'dataquery'}),
458+
'values': t('Values', {ns: 'dataquery'}),
458459
}}
459-
label='Display options as'
460+
label={t('Display options as', {ns: 'dataquery'})}
460461
value={enumDisplay == EnumDisplayTypes.EnumLabel
461462
? 'labels'
462463
: 'values'}

modules/dataquery/jsx/welcome.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ function IntroductionMessage(props: {
11141114
+'fields used by the query. It will display in a Shared Queries panel '
11151115
+'below the Recent Queries.', {ns: 'dataquery'})}</p>
11161116
<p>{t('You may also give a query a name at any time by clicking the icon.'
1117-
+'This makes it easier to find queries you care about by giving them an'
1117+
+' This makes it easier to find queries you care about by giving them an'
11181118
+' easier to remember name that can be used for filtering. When you '
11191119
+'share a query, the name will be shared along with it.',
11201120
{ns: 'dataquery'})}</p>

modules/dataquery/locale/dataquery.pot

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,63 @@ msgstr ""
404404

405405
msgid "Filters"
406406
msgstr ""
407+
408+
msgid "Continue to Define Fields"
409+
msgstr ""
410+
411+
msgid "Above, there is also a Study Queries panel. This are a special type of shared queries that have been pinned by a study administer to always display at the top of this page."
412+
msgstr ""
413+
414+
msgid "The data query tool allows you to query data within LORIS. There are three steps to defining a query:"
415+
msgstr ""
416+
417+
msgid "First, you must select the fields that you're interested in on the Define Fields page."
418+
msgstr ""
419+
420+
msgid "Next, you can optionally define filters on the Define Filters page to restrict the population that is returned."
421+
msgstr ""
422+
423+
msgid "Finally, you view your query results on the View Data page"
424+
msgstr ""
425+
426+
msgid "The Next Steps on the bottom right of your screen always the context-sensitive next steps that you can do to build your query."
427+
msgstr ""
428+
429+
msgid "Your recently run queries will be displayed in the Recent Queries panel below. Instead of building a new query, you can reload a query that you've recently run by clicking on the icon next to the query."
430+
msgstr ""
431+
432+
msgid "Queries can be shared with others by clicking the icon. This will cause the query to be shared with all users who have access to the fields used by the query. It will display in a Shared Queries panel below the Recent Queries."
433+
msgstr ""
434+
435+
msgid "You may also give a query a name at any time by clicking the icon. This makes it easier to find queries you care about by giving them an easier to remember name that can be used for filtering. When you share a query, the name will be shared along with it."
436+
msgstr ""
437+
438+
msgid "Selected Fields"
439+
msgstr ""
440+
441+
msgid "Available Fields"
442+
msgstr ""
443+
444+
msgid "Add all"
445+
msgstr ""
446+
447+
msgid "Remove all"
448+
msgstr ""
449+
450+
msgid "Filter within category"
451+
msgstr ""
452+
453+
msgid "Default Visits"
454+
msgstr ""
455+
456+
msgid "Sync with selected fields"
457+
msgstr ""
458+
459+
msgid "Select a field"
460+
msgstr ""
461+
462+
msgid "Select a category"
463+
msgstr ""
464+
465+
msgid "Invalid response"
466+
msgstr ""

0 commit comments

Comments
 (0)