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

feat: create i18n package #6945

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions apps/site/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const loadLocaleDictionary = async (locale: string) => {
if (locale === 'en') {
// This enables HMR on the English Locale, so that instant refresh
// happens while we add/change texts on the source locale
return import('./i18n/locales/en.json').then(f => f.default);
return import('@nodejs/i18n/locales/en.json').then(f => f.default);
}

if (availableLocaleCodes.includes(locale)) {
// Other languages don't really require HMR as they will never be development languages
// so we can load them dynamically
return import(`./i18n/locales/${locale}.json`).then(f => f.default);
return import(`@nodejs/i18n/locales/${locale}.json`).then(f => f.default);
}

throw new Error(`Unsupported locale: ${locale}`);
Expand Down
2 changes: 1 addition & 1 deletion apps/site/next.locales.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this file should be on package i18n. So it's can be share between multiple apps.

Copy link
Collaborator

Choose a reason for hiding this comment

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

agree


import localeConfig from './i18n/config.json' assert { type: 'json' };
import localeConfig from '@nodejs/i18n/config.json' assert { type: 'json' };

// As set of available and enabled locales for the website
// This is used for allowing us to redirect the user to any
Expand Down
1 change: 1 addition & 0 deletions apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"@heroicons/react": "~2.1.1",
"@mdx-js/mdx": "^3.0.1",
"@nodejs/i18n": "^0.1.0",
"@nodevu/core": "~0.1.0",
"@orama/highlight": "^0.1.6",
"@oramacloud/client": "^1.3.2",
Expand Down
1 change: 1 addition & 0 deletions apps/site/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
]
},
"build": {
"dependsOn": ["^build"],
"inputs": [
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx}",
"{app,components,layouts,pages,styles}/**/*.css",
Expand Down
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
"packageManager": "[email protected]",
"workspaces": [
"apps/*"
"apps/*",
"packages/*"
],
"scripts": {
"dev": "turbo run dev",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions packages/i18n/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@nodejs/i18n",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this scope, we should have one specific to the website because this one is also used apr undici. The packages in nodejs are user packages, so it's not the best idea. But there's also @node-core, which doesn't fit either because it's intended for node core 😁.
So for me it would be necessary to have a scope specific to the website project.

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be "@node-core/website-i18n" and the current "@nodejs/website" on (apps/site) should be "@node-core/website"

Copy link
Collaborator

Choose a reason for hiding this comment

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

i am fine with that - one thing to keep in mind is that we cannot anticipate how people will use these packages once split out. @node-core/website-i18n could suddenly become very useful to someone downstream. That's not to say we should optimize for unknown, but I do like re-use.

"private": true,
"version": "0.1.0",
"license": "MIT"
}
12 changes: 10 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
"outputs": [".prettiercache"]
},
"lint": {
"dependsOn": ["lint:md", "lint:css", "lint:js"]
"dependsOn": [
"@nodejs/website#lint:md",
"@nodejs/website#lint:css",
"@nodejs/website#lint:js"
]
},
"lint:lint-staged": {
"dependsOn": ["lint:md", "lint:css", "lint:js"]
"dependsOn": [
"@nodejs/website#lint:md",
"@nodejs/website#lint:css",
"@nodejs/website#lint:js"
]
},
"check-types": {
"dependsOn": ["^topo"]
Expand Down
Loading