Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly replace umlauts and Eszett for German lang #2616

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/common/src/normalize-string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ describe('normalizeString()', () => {
expect(normalizeString('Capture d’écran')).toBe('capture decran');
expect(normalizeString('Capture d‘écran')).toBe('capture decran');
});

it('replaces eszett with double-s digraph', () => {
expect(normalizeString('KONGREẞ im Straßennamen')).toBe('kongress im strassennamen');
});

// works for German language, might not work for e.g. Finnish language
it('replaces combining diaeresis with e', () => {
expect(normalizeString('Ja quäkt Schwyz Pöbel vor Gmünd')).toBe('ja quaekt schwyz poebel vor gmuend');
});
});
3 changes: 3 additions & 0 deletions packages/common/src/normalize-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
export function normalizeString(input: string, spaceReplacer = ' '): string {
return (input || '')
.normalize('NFD')
.replace(/[\u00df]/g, 'ss')
.replace(/[\u1e9e]/g, 'SS')
.replace(/[\u0308]/g, 'e')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.replace(/[!"£$%^&*()+[\]{};:@#~?\\/,|><`¬'=‘’©®™]/g, '')
Expand Down
6 changes: 3 additions & 3 deletions packages/core/e2e/collection.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ describe('Collection resolver', () => {
'accessories',
);
expect(createCollection.translations.find(t => t.languageCode === LanguageCode.de)?.slug).toBe(
'zubehor',
'zubehoer',
);
});

Expand Down Expand Up @@ -285,7 +285,7 @@ describe('Collection resolver', () => {
'accessories-2',
);
expect(createCollection.translations.find(t => t.languageCode === LanguageCode.de)?.slug).toBe(
'zubehor-2',
'zubehoer-2',
);
});

Expand Down Expand Up @@ -317,7 +317,7 @@ describe('Collection resolver', () => {
'accessories',
);
expect(createCollection.translations.find(t => t.languageCode === LanguageCode.de)?.slug).toBe(
'zubehor',
'zubehoer',
);
});

Expand Down
Loading