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

[Issue #1937] Translate Loading component text #2186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mdragon
Copy link
Collaborator

@mdragon mdragon commented Sep 20, 2024

Summary

Fixes #1937

Time to review: 5 mins

Changes proposed

Implemented the translation library for the text on the Search loading spinner

Context for reviewers

This component is currently under the Search page, but seems like we'd likely reuse it elsewhere. Since file moves are weird to PR and revert I wanted to get more input before moving stuff around.

Additional information

Tested by implementing Storybook for this component
image

…al for non-search loading translation as well

Fixes #1937
Copy link

Coverage report for ./frontend

St.
Category Percentage Covered / Total
🟢 Statements 90.6% 790/872
🟡 Branches 71.79% 224/312
🟢 Functions 87.89% 167/190
🟢 Lines 91.27% 742/813

Test suite run success

178 tests passing in 54 suites.

Report generated by 🧪jest coverage report action from 7316673

import React from "react";

import Spinner from "src/components/Spinner";

export default function Loading() {
// TODO (Issue #1937): Use translation utility for strings in this file
const t = useTranslations("Loading");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const t = useTranslations("Loading");
unstable_setRequestLocale("en");
const t = useTranslations("Loading");

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Making these changes causes the following error in Storybook:
image

Looks like this might not be needed at the component level?
https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#add-unstable_setrequestlocale-to-all-layouts-and-pages

@@ -1,14 +1,16 @@
import { useTranslations } from "next-intl";
import React from "react";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import React from "react";
import { unstable_setRequestLocale } from "next-intl/server";
import React from "react";

@acouch
Copy link
Collaborator

acouch commented Sep 20, 2024

Looks good, think you need to add unstable_setRequestLocale(). See amannn/next-intl#663 and https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering . We might be able to pass in the locale instead of just default to "en". We didn't do that previously because the next-intl was setup in parts and we did not update that until we fully moved over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Update Loading spinner "Loading results..." to use translation utility
2 participants