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

Add pathPrefix to i18n and use storefront.i18n #330

Merged
merged 7 commits into from
Jan 12, 2023

Conversation

frandiox
Copy link
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
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
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
Contributor

love this, great stuff @frandiox

Copy link
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

@@ -5,7 +5,7 @@ import {Await, useLoaderData} from '@remix-run/react';
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
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
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