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 i18n support #90

Merged
merged 18 commits into from
Jan 15, 2024
Merged

Add i18n support #90

merged 18 commits into from
Jan 15, 2024

Conversation

foyarash
Copy link
Collaborator

#68

Copy link

changeset-bot bot commented Dec 13, 2023

🦋 Changeset detected

Latest commit: 1b5dd6d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@premieroctet/next-admin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -0,0 +1,20 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

It's easier to maintain flat translation file like

admin.actions.user.email.title

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This nested notation is the only one supported by next-intl

Comment on lines +19 to +29
const t = (key: string, options?: { [key: string]: any }) => {
let translation = translations[key];

if (options && translation) {
Object.entries(options).forEach(([key, value]) => {
translation = translation!.replace(`{{${key}}}`, value);
});
}

return translation ?? key;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test for this function ?

@foyarash foyarash requested a review from tlenclos December 14, 2023 14:24
@cregourd cregourd changed the title feat: add i18n support Add i18n support Jan 8, 2024
@cregourd cregourd merged commit 112399c into main Jan 15, 2024
3 checks passed
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.

3 participants