Skip to content

Commit 46e479c

Browse files
authored
Merge pull request #1454 from navikt/fix/forms-api-filter-out-countries-in-form-translations
Filter out countries in form translations
2 parents 97ad3ba + b758c75 commit 46e479c

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Diff for: packages/bygger/src/context/translations/EditFormTranslationsContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@ const EditFormTranslationsProvider = ({ initialChanges, children }: Props) => {
106106

107107
const useEditFormTranslations = () => useContext(EditFormTranslationsContext);
108108

109-
export { EditFormTranslationsContext, useEditFormTranslations };
109+
export { useEditFormTranslations };
110110
export default EditFormTranslationsProvider;

Diff for: packages/bygger/src/context/translations/EditGlobalTranslationsContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,5 @@ const EditGlobalTranslationsProvider = ({ initialChanges, children }: Props) =>
149149

150150
const useEditGlobalTranslations = () => useContext(EditGlobalTranslationsContext);
151151

152-
export { EditGlobalTranslationsContext, useEditGlobalTranslations };
152+
export { useEditGlobalTranslations };
153153
export default EditGlobalTranslationsProvider;

Diff for: packages/bygger/src/translations/utils/editFormTranslationsUtils.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getCountries } from '@navikt/skjemadigitalisering-shared-components';
12
import { Form, FormsApiFormTranslation, FormsApiGlobalTranslation } from '@navikt/skjemadigitalisering-shared-domain';
23
import { getFormTexts } from '../../old_translations/utils';
34

@@ -29,11 +30,18 @@ const generateAndPopulateTranslationsForForm = (
2930
globalTranslations: Record<string, FormsApiGlobalTranslation>,
3031
): FormsApiFormTranslation[] => {
3132
const textObjects = getFormTexts(form, false);
33+
const countries = getCountries('nb');
3234

33-
return textObjects.map(({ text }) => {
34-
const populatedTranslation = populateFromStoredTranslations(text, storedTranslations);
35-
return checkForGlobalOverride(populatedTranslation, globalTranslations);
36-
});
35+
return (
36+
textObjects
37+
// We filter out any country names to avoid having to maintain their translations
38+
// All country names on 'nn' and 'en' are added from a third party package when we build the i18n object in FyllUt
39+
.filter(({ text }) => !countries.some((country) => country.label === text))
40+
.map(({ text }) => {
41+
const populatedTranslation = populateFromStoredTranslations(text, storedTranslations);
42+
return checkForGlobalOverride(populatedTranslation, globalTranslations);
43+
})
44+
);
3745
};
3846

3947
export { generateAndPopulateTranslationsForForm };

0 commit comments

Comments
 (0)