Skip to content

Commit

Permalink
A few more item groups (#160)
Browse files Browse the repository at this point in the history
## Description

After going through all the existing incentives and giving them more
granular items, I found some common combinations that are worth
handling: door/window replacement, and audits plus weatherization.

There was one combined incentive (CO's state tax credit for air source
heat pumps and HPWHs) which I elected to split into two incentives; it
felt too awkward to create a group for those technologies.

## Test Plan

Unit test.

I found all the multi-item combos in the incentives data by running
this in the incentives repo:

`echo data/**/incentives.json | xargs jq '.[] | select((.items | length)
> 1) | .items | sort | join(",")' | sort | uniq`

There are no combos in there that will result in null here.
  • Loading branch information
oyamauchi authored May 15, 2024
1 parent 6f0f722 commit 2332ab5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/i18n/strings/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const templates = {
s025c15001425a689: `reemplazo de ventanas`,
s04009ba1826b5fca: `Idaho`,
s04c4b18eb3941d37: `California`,
s07607bad0f288304: `reemplazo de puertas y ventanas`,
s07ecbff17886eb50: `un vehículo eléctrico usado`,
s08fb6007b5965c82: `Vehículo eléctrico`,
s0ec469a91a15f4a5: `kilovatio hora`,
Expand Down Expand Up @@ -95,6 +96,7 @@ export const templates = {
s6ef16f759a2cea7e: `Nevada`,
s70fd14cbb0ad4160: `Continúe para ver otros incentivos.`,
s751ba5ac47cbfabb: `Washington`,
s7709947cefee8560: `una auditoría energética y impermeabilización`,
s777612e8117ff021: `Tennessee`,
s79fd9ba9e498d3da: str`${0} del costo de ${1}, hasta \$${2}`,
s7a73c90a7c3b43b4: `un calentador de agua con bomba de calor`,
Expand Down
65 changes: 41 additions & 24 deletions src/item-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,33 @@ type ItemGroup =
| 'plugin_hybrid'
| 'new_vehicle'
| 'used_vehicle'
| 'door_and_window'
| 'insulation'
| 'weatherization'
| 'audit_and_weatherization'
| 'water_heater';

const ALL_INSULATION: ItemType[] = [
'attic_or_roof_insulation',
'basement_insulation',
'crawlspace_insulation',
'floor_insulation',
'other_insulation',
'wall_insulation',
];

const ALL_WEATHERIZATION: ItemType[] = [
...ALL_INSULATION,
'air_sealing',
'door_replacement',
'duct_replacement',
'duct_sealing',
'weatherization',
'window_replacement',
'efficiency_rebates',
'other_weatherization',
];

/**
* Some incentives are for multiple items. These groups define headlines for
* such incentives: if the incentive's items are a subset of one of these
Expand Down Expand Up @@ -67,35 +90,21 @@ const ITEM_GROUPS: { group: ItemGroup; members: Set<ItemType> }[] = [
group: 'used_vehicle',
members: new Set(['used_electric_vehicle', 'used_plugin_hybrid_vehicle']),
},
{
group: 'door_and_window',
members: new Set(['door_replacement', 'window_replacement']),
},
{
group: 'insulation',
members: new Set([
'attic_or_roof_insulation',
'basement_insulation',
'crawlspace_insulation',
'floor_insulation',
'other_insulation',
'wall_insulation',
]),
members: new Set(ALL_INSULATION),
},
{
group: 'weatherization',
members: new Set([
'air_sealing',
'attic_or_roof_insulation',
'basement_insulation',
'crawlspace_insulation',
'door_replacement',
'duct_replacement',
'duct_sealing',
'floor_insulation',
'wall_insulation',
'weatherization',
'window_replacement',
'efficiency_rebates',
'other_insulation',
'other_weatherization',
]),
members: new Set(ALL_WEATHERIZATION),
},
{
group: 'audit_and_weatherization',
members: new Set([...ALL_WEATHERIZATION, 'energy_audit']),
},
{
group: 'water_heater',
Expand Down Expand Up @@ -139,12 +148,20 @@ const multipleItemsName = (items: ItemType[], msg: MsgFn) => {
});
case 'generic_heat_pump':
return msg('a heat pump', { desc: 'e.g. "$100 off [this string]"' });
case 'door_and_window':
return msg('door and window replacement', {
desc: 'e.g. "$100 off [this string]"',
});
case 'insulation':
return msg('insulation', { desc: 'e.g. "$100 off [this string]"' });
case 'weatherization':
return msg('weatherization', {
desc: 'e.g. "$100 off [this string]"',
});
case 'audit_and_weatherization':
return msg('an energy audit and weatherization', {
desc: 'e.g. "$100 off [this string]"',
});
case 'water_heater':
return msg('a water heater', {
desc: 'e.g. "$100 off [this string]"',
Expand Down
4 changes: 3 additions & 1 deletion test/item-names.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe('group names', () => {
expect(itemName(['wall_insulation', 'other_weatherization'], msg)).toBe(
'weatherization',
);
expect(itemName(['other_weatherization', 'energy_audit'], msg)).toBeNull();
expect(itemName(['other_weatherization', 'energy_audit'], msg)).toBe(
'an energy audit and weatherization',
);
});

test('vehicles', () => {
Expand Down
10 changes: 10 additions & 0 deletions translations/es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,16 @@
<target>un vehículo usado</target>
<note from="lit-localize">e.g. "$100 off [this string]"</note>
</trans-unit>
<trans-unit id="s07607bad0f288304">
<source>door and window replacement</source>
<target>reemplazo de puertas y ventanas</target>
<note from="lit-localize">e.g. "$100 off [this string]"</note>
</trans-unit>
<trans-unit id="s7709947cefee8560">
<source>an energy audit and weatherization</source>
<target>una auditoría energética y impermeabilización</target>
<note from="lit-localize">e.g. "$100 off [this string]"</note>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 2332ab5

Please sign in to comment.