Skip to content

Add pathPrefix to i18n and use storefront.i18n#330

Merged
frandiox merged 7 commits intov0.x-2022-10from
fd-i18n-pathprefix
Jan 12, 2023
Merged

Add pathPrefix to i18n and use storefront.i18n#330
frandiox merged 7 commits intov0.x-2022-10from
fd-i18n-pathprefix

Conversation

@frandiox
Copy link
Copy Markdown
Contributor

We were calling the getLocaleFromRequest in many loaders but we already have the same information in storefront.i18n. This PR starts using that instead. Also, it adds pathPrefix to the types of the i18n with a default value.
Thoughts?

On a side note, it's unfortunate that storefront.i18n is possibly undefined, even though we are passing a value in createStorefrontClient but we can't infer it, so we always need to access it as storefront.i18n!. Should we add a default value of {language: 'EN', country: 'US'} to storefront.i18n to improve the type? Would this default value be a problem?

@frandiox frandiox requested a review from a team December 14, 2022 04:56
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I like the idea of always having a default i18n to make the type more easy to work with.

@frandiox
Copy link
Copy Markdown
Contributor Author

though I like the idea of always having a default i18n to make the type more easy to work with.

I can change that in this PR. @jplhomer @wizardlyhel do you see any concern with that?

@juanpprieto
Copy link
Copy Markdown
Contributor

love this, great stuff @frandiox

Copy link
Copy Markdown
Contributor

@juanpprieto juanpprieto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

import {ProductSwimlane, FeaturedCollections, Hero} from '~/components';
import {COLLECTION_CONTENT_FRAGMENT, PRODUCT_CARD_FRAGMENT} from '~/data';
import {getHeroPlaceholder} from '~/lib/placeholders';
import {getLocaleFromRequest} from '~/lib/utils';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we delete this util?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still needed in server.ts to extract the locale from request the first time.

@frandiox frandiox merged commit 27f6270 into v0.x-2022-10 Jan 12, 2023
@frandiox frandiox deleted the fd-i18n-pathprefix branch January 12, 2023 15:53
@github-actions github-actions Bot mentioned this pull request Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants