Skip to content

Commit

Permalink
better translations (#371)
Browse files Browse the repository at this point in the history
* better importing for scripts

* undo yarn.lock
  • Loading branch information
huang0h authored Jul 8, 2024
1 parent 13a2713 commit 767b344
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 254 deletions.
2 changes: 1 addition & 1 deletion src/components/forms/updateSiteForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const UpdateSiteForm: React.FC<UpdateSiteFormProps> = ({
onFinish,
initialSiteEntry,
}) => {
const { t } = useTranslation(n(site, ['treeInfoTypes', 'forms']), {
const { t } = useTranslation(n(site, ['types', 'forms']), {
nsMode: 'fallback',
});

Expand Down
20 changes: 10 additions & 10 deletions src/components/navBar/translationDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import i18n from 'i18next';
import { GlobalOutlined } from '@ant-design/icons';
import { LOCALSTORAGE_I18N_KEY } from '../../i18n/i18n';
import styled from 'styled-components';
import { languages } from '../../i18n/i18n';

const items: MenuProps['items'] = [
{
key: 'en',
label: 'English',
},
{
key: 'es',
label: 'Español',
},
];
// Convert language codes to items whose display is the language name
const items: MenuProps['items'] = languages.map((langCode) => {
const languageName =
new Intl.DisplayNames(langCode, { type: 'language' }).of(langCode) || '';
return {
key: langCode,
label: languageName[0].toUpperCase() + languageName.slice(1),
};
});

const triggerChangeLang: MenuProps['onClick'] = ({ key }) => {
i18n.changeLanguage(key);
Expand Down
174 changes: 87 additions & 87 deletions src/containers/treePage/ducks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,111 +150,111 @@ export interface SplitSiteEntries {
}

export const MainSiteEntryNames: Record<string, string> = {
createdAt: t('main.createdAt', { ns: 'treeInfoTypes' }),
status: t('main.status', { ns: 'treeInfoTypes' }),
genus: t('main.genus', { ns: 'treeInfoTypes' }),
species: t('main.species', { ns: 'treeInfoTypes' }),
commonName: t('main.commonName', { ns: 'treeInfoTypes' }),
diameter: t('main.diameter', { ns: 'treeInfoTypes' }),
createdAt: t('main.createdAt', { ns: 'types' }),
status: t('main.status', { ns: 'types' }),
genus: t('main.genus', { ns: 'types' }),
species: t('main.species', { ns: 'types' }),
commonName: t('main.commonName', { ns: 'types' }),
diameter: t('main.diameter', { ns: 'types' }),
};

export const MainSiteEntryOrder: Record<string, number> = {
[t('main.createdAt', { ns: 'treeInfoTypes' })]: 1,
[t('main.commonName', { ns: 'treeInfoTypes' })]: 2,
[t('main.genus', { ns: 'treeInfoTypes' })]: 3,
[t('main.species', { ns: 'treeInfoTypes' })]: 4,
[t('main.scientificName', { ns: 'treeInfoTypes' })]: 3,
[t('main.diameter', { ns: 'treeInfoTypes' })]: 5,
[t('main.status', { ns: 'treeInfoTypes' })]: 6,
[t('main.createdAt', { ns: 'types' })]: 1,
[t('main.commonName', { ns: 'types' })]: 2,
[t('main.genus', { ns: 'types' })]: 3,
[t('main.species', { ns: 'types' })]: 4,
[t('main.scientificName', { ns: 'types' })]: 3,
[t('main.diameter', { ns: 'types' })]: 5,
[t('main.status', { ns: 'types' })]: 6,
};

export const ExtraSiteEntryNames: Record<string, string> = {
// SFTT
treePresent: t('sftt.treePresent', { ns: 'treeInfoTypes' }),
updatedAt: t('sftt.updatedAt', { ns: 'treeInfoTypes' }),
confidence: t('sftt.confidence', { ns: 'treeInfoTypes' }),
circumference: t('sftt.circumference', { ns: 'treeInfoTypes' }),
multistem: t('sftt.multistem', { ns: 'treeInfoTypes' }),
coverage: t('sftt.coverage', { ns: 'treeInfoTypes' }),
pruning: t('sftt.pruning', { ns: 'treeInfoTypes' }),
condition: t('sftt.condition', { ns: 'treeInfoTypes' }),
discoloring: t('sftt.discoloring', { ns: 'treeInfoTypes' }),
leaning: t('sftt.leaning', { ns: 'treeInfoTypes' }),
constrictingGrate: t('sftt.constrictingGrate', { ns: 'treeInfoTypes' }),
wounds: t('sftt.wounds', { ns: 'treeInfoTypes' }),
pooling: t('sftt.pooling', { ns: 'treeInfoTypes' }),
stakesWithWires: t('sftt.stakesWithWires', { ns: 'treeInfoTypes' }),
stakesWithoutWires: t('sftt.stakesWithoutWires', { ns: 'treeInfoTypes' }),
light: t('sftt.light', { ns: 'treeInfoTypes' }),
bicycle: t('sftt.bicycle', { ns: 'treeInfoTypes' }),
bagEmpty: t('sftt.bagEmpty', { ns: 'treeInfoTypes' }),
bagFilled: t('sftt.bagFilled', { ns: 'treeInfoTypes' }),
tape: t('sftt.tape', { ns: 'treeInfoTypes' }),
suckerGrowth: t('sftt.suckerGrowth', { ns: 'treeInfoTypes' }),
siteType: t('sftt.siteType', { ns: 'treeInfoTypes' }),
sidewalkWidth: t('sftt.sidewalkWidth', { ns: 'treeInfoTypes' }),
siteWidth: t('sftt.siteWidth', { ns: 'treeInfoTypes' }),
siteLength: t('sftt.siteLength', { ns: 'treeInfoTypes' }),
material: t('sftt.material', { ns: 'treeInfoTypes' }),
raisedBed: t('sftt.raisedBed', { ns: 'treeInfoTypes' }),
fence: t('sftt.fence', { ns: 'treeInfoTypes' }),
trash: t('sftt.trash', { ns: 'treeInfoTypes' }),
wires: t('sftt.wires', { ns: 'treeInfoTypes' }),
grate: t('sftt.grate', { ns: 'treeInfoTypes' }),
stump: t('sftt.stump', { ns: 'treeInfoTypes' }),
treeNotes: t('sftt.treeNotes', { ns: 'treeInfoTypes' }),
siteNotes: t('sftt.siteNotes', { ns: 'treeInfoTypes' }),
plantingDate: t('sftt.plantingDate', { ns: 'treeInfoTypes' }),
editEntry: t('sftt.editEntry', { ns: 'treeInfoTypes' }),
deleteEntry: t('sftt.deleteEntry', { ns: 'treeInfoTypes' }),
treePresent: t('sftt.treePresent', { ns: 'types' }),
updatedAt: t('sftt.updatedAt', { ns: 'types' }),
confidence: t('sftt.confidence', { ns: 'types' }),
circumference: t('sftt.circumference', { ns: 'types' }),
multistem: t('sftt.multistem', { ns: 'types' }),
coverage: t('sftt.coverage', { ns: 'types' }),
pruning: t('sftt.pruning', { ns: 'types' }),
condition: t('sftt.condition', { ns: 'types' }),
discoloring: t('sftt.discoloring', { ns: 'types' }),
leaning: t('sftt.leaning', { ns: 'types' }),
constrictingGrate: t('sftt.constrictingGrate', { ns: 'types' }),
wounds: t('sftt.wounds', { ns: 'types' }),
pooling: t('sftt.pooling', { ns: 'types' }),
stakesWithWires: t('sftt.stakesWithWires', { ns: 'types' }),
stakesWithoutWires: t('sftt.stakesWithoutWires', { ns: 'types' }),
light: t('sftt.light', { ns: 'types' }),
bicycle: t('sftt.bicycle', { ns: 'types' }),
bagEmpty: t('sftt.bagEmpty', { ns: 'types' }),
bagFilled: t('sftt.bagFilled', { ns: 'types' }),
tape: t('sftt.tape', { ns: 'types' }),
suckerGrowth: t('sftt.suckerGrowth', { ns: 'types' }),
siteType: t('sftt.siteType', { ns: 'types' }),
sidewalkWidth: t('sftt.sidewalkWidth', { ns: 'types' }),
siteWidth: t('sftt.siteWidth', { ns: 'types' }),
siteLength: t('sftt.siteLength', { ns: 'types' }),
material: t('sftt.material', { ns: 'types' }),
raisedBed: t('sftt.raisedBed', { ns: 'types' }),
fence: t('sftt.fence', { ns: 'types' }),
trash: t('sftt.trash', { ns: 'types' }),
wires: t('sftt.wires', { ns: 'types' }),
grate: t('sftt.grate', { ns: 'types' }),
stump: t('sftt.stump', { ns: 'types' }),
treeNotes: t('sftt.treeNotes', { ns: 'types' }),
siteNotes: t('sftt.siteNotes', { ns: 'types' }),
plantingDate: t('sftt.plantingDate', { ns: 'types' }),
editEntry: t('sftt.editEntry', { ns: 'types' }),
deleteEntry: t('sftt.deleteEntry', { ns: 'types' }),
// CAMBRIDGE
trunks: t('cambridge.trunks', { ns: 'treeInfoTypes' }),
speciesShort: t('cambridge.speciesShort', { ns: 'treeInfoTypes' }),
location: t('cambridge.location', { ns: 'treeInfoTypes' }),
siteRetiredReason: t('cambridge.siteRetiredReason', { ns: 'treeInfoTypes' }),
inspectr: t('cambridge.inspectr', { ns: 'treeInfoTypes' }),
abutsOpenArea: t('cambridge.abutsOpenArea', { ns: 'treeInfoTypes' }),
treeWellCover: t('cambridge.treeWellCover', { ns: 'treeInfoTypes' }),
trunks: t('cambridge.trunks', { ns: 'types' }),
speciesShort: t('cambridge.speciesShort', { ns: 'types' }),
location: t('cambridge.location', { ns: 'types' }),
siteRetiredReason: t('cambridge.siteRetiredReason', { ns: 'types' }),
inspectr: t('cambridge.inspectr', { ns: 'types' }),
abutsOpenArea: t('cambridge.abutsOpenArea', { ns: 'types' }),
treeWellCover: t('cambridge.treeWellCover', { ns: 'types' }),
treeGrateActionReq: t('cambridge.treeGrateActionReq', {
ns: 'treeInfoTypes',
ns: 'types',
}),
globalId: t('cambridge.globalId', { ns: 'treeInfoTypes' }),
pb: t('cambridge.pb', { ns: 'treeInfoTypes' }),
siteReplanted: t('cambridge.siteReplanted', { ns: 'treeInfoTypes' }),
overheadWires: t('cambridge.overheadWires', { ns: 'treeInfoTypes' }),
ownership: t('cambridge.ownership', { ns: 'treeInfoTypes' }),
scheduledRemoval: t('cambridge.scheduledRemoval', { ns: 'treeInfoTypes' }),
structuralSoil: t('cambridge.structuralSoil', { ns: 'treeInfoTypes' }),
globalId: t('cambridge.globalId', { ns: 'types' }),
pb: t('cambridge.pb', { ns: 'types' }),
siteReplanted: t('cambridge.siteReplanted', { ns: 'types' }),
overheadWires: t('cambridge.overheadWires', { ns: 'types' }),
ownership: t('cambridge.ownership', { ns: 'types' }),
scheduledRemoval: t('cambridge.scheduledRemoval', { ns: 'types' }),
structuralSoil: t('cambridge.structuralSoil', { ns: 'types' }),
wateringResponsibility: t('cambridge.wateringResponsibility', {
ns: 'treeInfoTypes',
ns: 'types',
}),
cultivar: t('cambridge.cultivar', { ns: 'treeInfoTypes' }),
solarRating: t('cambridge.solarRating', { ns: 'treeInfoTypes' }),
bareRoot: t('cambridge.bareRoot', { ns: 'treeInfoTypes' }),
adaCompliant: t('cambridge.adaCompliant', { ns: 'treeInfoTypes' }),
cultivar: t('cambridge.cultivar', { ns: 'types' }),
solarRating: t('cambridge.solarRating', { ns: 'types' }),
bareRoot: t('cambridge.bareRoot', { ns: 'types' }),
adaCompliant: t('cambridge.adaCompliant', { ns: 'types' }),
cartegraphPlantDate: t('cambridge.cartegraphPlantDate', {
ns: 'treeInfoTypes',
ns: 'types',
}),
locationRetired: t('cambridge.locationRetired', { ns: 'treeInfoTypes' }),
createdDate: t('cambridge.createdDate', { ns: 'treeInfoTypes' }),
order: t('cambridge.order', { ns: 'treeInfoTypes' }),
plantingSeason: t('cambridge.plantingSeason', { ns: 'treeInfoTypes' }),
exposedRootFlare: t('cambridge.exposedRootFlare', { ns: 'treeInfoTypes' }),
stTreePruningZone: t('cambridge.stTreePruningZone', { ns: 'treeInfoTypes' }),
memTree: t('cambridge.memTree', { ns: 'treeInfoTypes' }),
locationRetired: t('cambridge.locationRetired', { ns: 'types' }),
createdDate: t('cambridge.createdDate', { ns: 'types' }),
order: t('cambridge.order', { ns: 'types' }),
plantingSeason: t('cambridge.plantingSeason', { ns: 'types' }),
exposedRootFlare: t('cambridge.exposedRootFlare', { ns: 'types' }),
stTreePruningZone: t('cambridge.stTreePruningZone', { ns: 'types' }),
memTree: t('cambridge.memTree', { ns: 'types' }),
cartegraphRetireDate: t('cambridge.cartegraphRetireDate', {
ns: 'treeInfoTypes',
ns: 'types',
}),
removalReason: t('cambridge.removalReason', { ns: 'treeInfoTypes' }),
removalReason: t('cambridge.removalReason', { ns: 'types' }),
offStTreePruningZone: t('cambridge.offStTreePruningZone', {
ns: 'treeInfoTypes',
ns: 'types',
}),
plantingContract: t('cambridge.plantingContract', { ns: 'treeInfoTypes' }),
treeWellDepth: t('cambridge.treeWellDepth', { ns: 'treeInfoTypes' }),
removalDate: t('cambridge.removalDate', { ns: 'treeInfoTypes' }),
scientificName: t('cambridge.scientificName', { ns: 'treeInfoTypes' }),
biocharAdded: t('cambridge.biocharAdded', { ns: 'treeInfoTypes' }),
lastEditedUser: t('cambridge.lastEditedUser', { ns: 'treeInfoTypes' }),
plantingContract: t('cambridge.plantingContract', { ns: 'types' }),
treeWellDepth: t('cambridge.treeWellDepth', { ns: 'types' }),
removalDate: t('cambridge.removalDate', { ns: 'types' }),
scientificName: t('cambridge.scientificName', { ns: 'types' }),
biocharAdded: t('cambridge.biocharAdded', { ns: 'types' }),
lastEditedUser: t('cambridge.lastEditedUser', { ns: 'types' }),
};

export interface TreeCare {
Expand Down
File renamed without changes.
80 changes: 53 additions & 27 deletions src/i18n/en/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,55 @@
// SFTT
export { default as landing } from './landing.json';
export { default as maps } from './maps.json';
export { default as notFound } from './notFound.json';
export { default as forgotPassword } from './forgotPassword.json';
export { default as forgotPasswordReset } from './forgotPasswordReset.json';
export { default as reports } from './reports.json';
export { default as login } from './login.json';
export { default as signup } from './signup.json';
export { default as home } from './home.json';
export { default as settings } from './settings.json';
export { default as faq } from './faq.json';
export { default as myTrees } from './myTrees.json';
export { default as site } from './site.json';
export { default as admin } from './admin.json';
import landing from './landing.json';
import maps from './maps.json';
import notFound from './notFound.json';
import forgotPassword from './forgotPassword.json';
import forgotPasswordReset from './forgotPasswordReset.json';
import reports from './reports.json';
import login from './login.json';
import signup from './signup.json';
import home from './home.json';
import settings from './settings.json';
import faq from './faq.json';
import myTrees from './myTrees.json';
import site from './site.json';
import admin from './admin.json';
import treePage from './treePage/treePage.json';
import treeInfo from './treePage/treeInfo.json';
import shareMenu from './treePage/shareMenu.json';
import treeActivity from './treePage/treeActivity.json';
import careEntry from './treePage/careEntry.json';
import types from './treePage/types.json';
import forms from './forms.json';
import tables from './tables.json';
import content from './content.json';
import cambridgeLanding from './cambridgeLanding.json';

export { default as treePage } from './treePage/treePage.json';
export { default as treeInfo } from './treePage/treeInfo.json';
export { default as shareMenu } from './treePage/shareMenu.json';
export { default as treeActivity } from './treePage/treeActivity.json';
export { default as careEntry } from './treePage/careEntry.json';
export { default as treeInfoTypes } from './treePage/types.json';
const translations = {
en: {
landing,
maps,
notFound,
forgotPassword,
forgotPasswordReset,
reports,
login,
signup,
home,
settings,
faq,
myTrees,
site,
admin,
treePage,
treeInfo,
shareMenu,
treeActivity,
careEntry,
types,
forms,
tables,
content,
cambridgeLanding,
},
};

export { default as forms } from './forms.json';
export { default as tables } from './tables.json';
export { default as content } from './content.json';

// CAMBRIDGE
export { default as cambridgeLanding } from './cambridge-landing.json';
export default translations;
Empty file removed src/i18n/en/siteImageReview.json
Empty file.
75 changes: 51 additions & 24 deletions src/i18n/es/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,53 @@
// SFTT
export { default as landingEs } from './landing.json';
export { default as mapsEs } from './maps.json';
export { default as notFoundEs } from './notFound.json';
export { default as forgotPasswordEs } from './forgotPassword.json';
export { default as forgotPasswordResetEs } from './forgotPasswordReset.json';
export { default as reportsEs } from './reports.json';
export { default as loginEs } from './login.json';
export { default as signupEs } from './signup.json';
export { default as homeEs } from './home.json';
export { default as settingsEs } from './settings.json';
export { default as faqEs } from './faq.json';
export { default as myTreesEs } from './myTrees.json';
export { default as siteEs } from './site.json';
export { default as adminEs } from './admin.json';
import landing from './landing.json';
import maps from './maps.json';
import notFound from './notFound.json';
import forgotPassword from './forgotPassword.json';
import forgotPasswordReset from './forgotPasswordReset.json';
import reports from './reports.json';
import login from './login.json';
import signup from './signup.json';
import home from './home.json';
import settings from './settings.json';
import faq from './faq.json';
import myTrees from './myTrees.json';
import site from './site.json';
import admin from './admin.json';
import treePage from './treePage/treePage.json';
import treeInfo from './treePage/treeInfo.json';
import shareMenu from './treePage/shareMenu.json';
import treeActivity from './treePage/treeActivity.json';
import careEntry from './treePage/careEntry.json';
import types from './treePage/types.json';
import forms from './forms.json';
import tables from './tables.json';
import content from './content.json';

export { default as treePageEs } from './treePage/treePage.json';
export { default as treeInfoEs } from './treePage/treeInfo.json';
export { default as shareMenuEs } from './treePage/shareMenu.json';
export { default as treeActivityEs } from './treePage/treeActivity.json';
export { default as careEntryEs } from './treePage/careEntry.json';
export { default as treeInfoTypesEs } from './treePage/types.json';
const translations = {
es: {
landing,
maps,
notFound,
forgotPassword,
forgotPasswordReset,
reports,
login,
signup,
home,
settings,
faq,
myTrees,
site,
admin,
treePage,
treeInfo,
shareMenu,
treeActivity,
careEntry,
types,
forms,
tables,
content,
},
};

export { default as formsEs } from './forms.json';
export { default as tablesEs } from './tables.json';
export { default as contentEs } from './content.json';
export default translations;
Empty file removed src/i18n/es/siteImageReview.json
Empty file.
Loading

0 comments on commit 767b344

Please sign in to comment.