-
Notifications
You must be signed in to change notification settings - Fork 167
feat(i18n): expand Chinese localization and fix env substitution #671
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
Open
sakuradairong
wants to merge
54
commits into
netbirdio:main
Choose a base branch
from
sakuradairong:localize-zh-v2.39.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
f2fc11b
feat(i18n): localize Peers, Access Control, Groups modules to Chinese
sakuradairong bd2c5ce
feat(i18n): localize Users, Service Users, Groups main pages
sakuradairong c4469af
feat(i18n): localize DNS, Reverse Proxy, Settings, Posture Checks, Ne…
sakuradairong 27fe310
feat(docker): containerize localized dashboard
sakuradairong da01b5b
feat(i18n): expand Chinese localization and fix env substitution
sakuradairong bb6c304
feat(i18n): localize remaining reverse proxy, table headers and modal…
sakuradairong 21e4ceb
fix(server): add comment explaining single-locale /zh fallback logic
sakuradairong 4bd5eda
fix(i18n): address CodeRabbit review — localize confirmation dialogs,…
sakuradairong 6c363b6
fix(i18n): localize RestrictedAccess component and add restrictedAcce…
sakuradairong 98a7923
feat(i18n): cookie-based locale detection with English default and sw…
sakuradairong c05a3ee
fix(i18n): localize remaining hardcoded UI strings across settings an…
sakuradairong 96f15d7
fix(i18n): localize remaining hardcoded titles in user detail, peers …
sakuradairong 2dc523c
fix(i18n): localize Cancel button text across 25 modal components
sakuradairong 77b413d
fix(i18n): localize aria-label attributes across 12 components
sakuradairong 50c2ffa
fix(i18n): localize Danger Zone account deletion text
sakuradairong 5c4df7a
merge: resolve conflict with origin/main (IdentityProviderModal logou…
sakuradairong d894c74
fix(i18n): localize Settings tab sub-categories (forms, labels, help …
sakuradairong bddc357
fix(i18n): localize Resource Access Control, Peer Expiration, Peer Se…
sakuradairong 055252d
Merge remote-tracking branch 'origin/main' into localize-zh-v2.39.0
sakuradairong 312c32f
fix(i18n): localize Peer sections and Posture Checks components
sakuradairong dc9c9d9
fix(i18n): localize RouteModal, SetupKeyModal, CreateAccessTokenModal
sakuradairong 8e40fd8
fix(i18n): localize IdentityProviderModal, ChangePasswordModal, Creat…
sakuradairong acf427d
fix(i18n): localize groups sections, DNS records, route modals, rever…
sakuradairong fcb1e8c
fix(i18n): localize UserInviteModal and team/user page
sakuradairong 0ccc0f9
fix(i18n): localize AuthenticationTab
sakuradairong c0fe4d0
fix(i18n): localize PeerMultiSelect and add route keys
sakuradairong c8eec5a
fix(i18n): add accessControlGroups and autoApply keys
sakuradairong 11ca0c6
Merge remote-tracking branch 'origin/main' into localize-zh-v2.39.0
sakuradairong e89c56b
fix(i18n): commit remaining locale changes for team/user, PeerMultiSe…
sakuradairong 9cd0d6c
fix(i18n): convert PeersTable columns to useTranslations
sakuradairong 249da77
fix(i18n): convert UsersTable columns to useTranslations
sakuradairong 722c9fb
fix(i18n): localize AccessTokensTable and SetupKeysTable columns
sakuradairong f9326f6
fix(i18n): localize PeerSSHToggle and PeerEditIPModal
sakuradairong fdc7af1
fix(i18n): localize peer SSH, edit IP, routes, access tokens and setu…
sakuradairong 9bbbeea
i18n: localize notifications module (channels, modals, events)
sakuradairong 3b870a0
i18n: localize reverse-proxy terminated service badge
sakuradairong 9d1cd3e
i18n: localize invoices module (tab, table, action cells, type cells)
sakuradairong 1e0b124
i18n: localize webhooks module (general, headers, auth, config)
sakuradairong 3cb8244
i18n: add survey and aws marketplace translation keys
sakuradairong a6f46b1
i18n: localize critical UI components into Chinese
46d20e5
i18n: localize remaining UI strings in users module
3bb1a61
i18n: localize Peers, Activity, Setup Keys modules
5eb928f
i18n: localize Routes, DNS, Networks, Access Control modules
2bd2e03
i18n: add untranslated English string baseline
2ce9f90
Merge remote-tracking branch 'origin/main' into localize-zh-v2.39.0
sakuradairong 7e4e2f0
fix(i18n): resolve build/type errors, sync main, and address CodeRabb…
sakuradairong d9b9bb5
i18n: remove unused navigation and routing modules
43a9649
i18n: add IntlMessages type augmentation for next-intl
1514a48
i18n: localize dashboard page metadata titles
92dc5b2
i18n: add translation keys for onboarding, posture checks and routes
b13b7de
i18n: localize onboarding intent, completion and demo-call screens
fdcf641
i18n: localize posture checks table and action components
083b5db
i18n: replace string concatenations with message interpolation
9bb8d2f
fix(i18n): use users namespace for admin label in service users table
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,13 @@ | ||
| FROM alpine:3.14 | ||
| FROM node:22-alpine | ||
|
|
||
| RUN apk add --no-cache bash curl less ca-certificates git tzdata zip gettext \ | ||
| nginx curl supervisor certbot-nginx && \ | ||
| rm -rf /var/cache/apk/* && mkdir -p /run/nginx | ||
| WORKDIR /usr/share/nginx/html | ||
|
|
||
| STOPSIGNAL SIGINT | ||
| EXPOSE 80 | ||
| EXPOSE 443 | ||
| ENTRYPOINT ["/usr/bin/supervisord","-c","/etc/supervisord.conf"] | ||
| # Copy build files | ||
| COPY out/ /usr/share/nginx/html/ | ||
|
|
||
| WORKDIR /usr/share/nginx/html | ||
| # copy configuration files | ||
| COPY docker/default.conf /etc/nginx/http.d/default.conf | ||
| COPY docker/nginx.conf /etc/nginx/nginx.conf | ||
| COPY docker/init_cert.sh /usr/local/init_cert.sh | ||
| COPY docker/init_react_envs.sh /usr/local/init_react_envs.sh | ||
| RUN chmod +x /usr/local/init_cert.sh && rm /etc/crontabs/root | ||
| RUN chmod +x /usr/local/init_react_envs.sh | ||
| # Copy server script | ||
| COPY docker/server.js /server.js | ||
|
|
||
| EXPOSE 80 | ||
|
|
||
| # configure supervisor | ||
| COPY docker/supervisord.conf /etc/supervisord.conf | ||
| # copy build files | ||
| COPY out/ /usr/share/nginx/html/ | ||
| CMD ["node", "/server.js"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| const http = require('http'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const root = path.resolve('/usr/share/nginx/html'); | ||
|
|
||
| const MIME = { | ||
| '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript', | ||
| '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg', | ||
| '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.wasm': 'application/wasm', | ||
| '.ttf': 'font/ttf', '.woff': 'font/woff', '.woff2': 'font/woff2', | ||
| '.txt': 'text/plain', '.xml': 'text/xml' | ||
| }; | ||
|
|
||
| // Replace both placeholder styles used by generated assets and templates. | ||
| const ENV_KEYS = [ | ||
| 'USE_AUTH0', | ||
| 'AUTH_AUDIENCE', | ||
| 'AUTH_AUTHORITY', | ||
| 'AUTH_CLIENT_ID', | ||
| 'AUTH_CLIENT_SECRET', | ||
| 'AUTH_SUPPORTED_SCOPES', | ||
| 'NETBIRD_MGMT_API_ENDPOINT', | ||
| 'NETBIRD_MGMT_GRPC_API_ENDPOINT', | ||
| 'NETBIRD_HOTJAR_TRACK_ID', | ||
| 'NETBIRD_GOOGLE_ANALYTICS_ID', | ||
| 'NETBIRD_GOOGLE_TAG_MANAGER_ID', | ||
| 'AUTH_REDIRECT_URI', | ||
| 'AUTH_SILENT_REDIRECT_URI', | ||
| 'NETBIRD_TOKEN_SOURCE', | ||
| 'NETBIRD_DRAG_QUERY_PARAMS', | ||
| 'NETBIRD_WASM_PATH', | ||
| 'AUTH0_DOMAIN', | ||
| 'AUTH0_CLIENT_ID', | ||
| 'AUTH0_AUDIENCE', | ||
| ]; | ||
|
|
||
| function substituteEnv(content) { | ||
| let changed = false; | ||
| for (const key of ENV_KEYS) { | ||
| const val = process.env[key] || ''; | ||
| for (const pattern of ['$$' + key, '$' + key]) { | ||
| if (content.includes(pattern)) { | ||
| content = content.split(pattern).join(val); | ||
| changed = true; | ||
| } | ||
| } | ||
| } | ||
| return { content, changed }; | ||
| } | ||
|
|
||
| function walkDir(dir) { | ||
| try { | ||
| const entries = fs.readdirSync(dir, { withFileTypes: true }); | ||
| for (const entry of entries) { | ||
| const full = path.join(dir, entry.name); | ||
| if (entry.isDirectory()) walkDir(full); | ||
| else if (entry.isFile() && /\.(js|html|txt|json)$/.test(entry.name)) { | ||
| const result = substituteEnv(fs.readFileSync(full, 'utf8')); | ||
| if (result.changed) fs.writeFileSync(full, result.content, 'utf8'); | ||
| } | ||
| } | ||
| } catch (e) { | ||
| console.warn('Failed to substitute environment variables:', e); | ||
| } | ||
| } | ||
|
|
||
| console.log('Substituting environment variables...'); | ||
| try { | ||
| const tmpl = path.join(root, 'OidcTrustedDomains.js.tmpl'); | ||
| if (fs.existsSync(tmpl)) { | ||
| const result = substituteEnv(fs.readFileSync(tmpl, 'utf8')); | ||
| fs.writeFileSync(path.join(root, 'OidcTrustedDomains.js'), result.content, 'utf8'); | ||
| } | ||
| } catch (e) { | ||
| console.warn('Failed to create OidcTrustedDomains.js:', e); | ||
| } | ||
|
|
||
| walkDir(root); | ||
| console.log('Environment substitution complete.'); | ||
|
|
||
| function isFile(p) { | ||
| try { return fs.statSync(p).isFile(); } catch(e) { return false; } | ||
| } | ||
|
|
||
| function safePath(p) { | ||
| const abs = path.resolve(root, '.' + p); | ||
| return abs === root || abs.startsWith(root + path.sep) ? abs : null; | ||
| } | ||
|
|
||
| function resolvePath(url) { | ||
| let p = url.split('?')[0]; | ||
| if (!p.startsWith('/')) p = '/' + p; | ||
| if (p === '/' || p.endsWith('/')) p += 'index.html'; | ||
| const abs = safePath(p); | ||
| if (abs && isFile(abs)) return abs; | ||
| // Try .html suffix (Next.js static export uses path.html) | ||
| const asHtml = safePath(p + '.html'); | ||
| if (asHtml && isFile(asHtml)) return asHtml; | ||
| // Try path/index.html | ||
| const asDirIndex = safePath(p + '/index.html'); | ||
| if (asDirIndex && isFile(asDirIndex)) return asDirIndex; | ||
| // Single-locale build: the static export places pages under /zh/. | ||
| // Fall back to /zh so that paths like /networks still resolve when the | ||
| // user navigates directly to a non-prefixed URL. | ||
| if (!p.startsWith('/zh')) { | ||
| const zh = safePath('/zh' + p); | ||
| if (zh && isFile(zh)) return zh; | ||
| const zhHtml = safePath('/zh' + p + '.html'); | ||
| if (zhHtml && isFile(zhHtml)) return zhHtml; | ||
| const zhDirIndex = safePath('/zh' + p + '/index.html'); | ||
| if (zhDirIndex && isFile(zhDirIndex)) return zhDirIndex; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| return null; | ||
| } | ||
|
|
||
| http.createServer((req, res) => { | ||
| const filePath = resolvePath(req.url); | ||
| if (filePath) { | ||
| const ext = path.extname(filePath); | ||
| fs.readFile(filePath, (err, data) => { | ||
| if (err) { send404(res); return; } | ||
| res.writeHead(200, { | ||
| 'Content-Type': MIME[ext] || 'application/octet-stream', | ||
| 'Cache-Control': ['.html', '.js'].includes(ext) ? 'no-store, no-cache, must-revalidate, max-age=0' : 'public, max-age=3600' | ||
| }); | ||
| res.end(data); | ||
| }); | ||
| } else { | ||
| send404(res); | ||
| } | ||
| }).listen(80, () => console.log('NetBird Dashboard running on port 80')); | ||
|
|
||
| function send404(res) { | ||
| fs.readFile(path.join(root, '404.html'), (err, data) => { | ||
| res.writeHead(404, {'Content-Type': 'text/html', 'Cache-Control': 'no-store'}); | ||
| res.end(err ? '404 Not Found' : data); | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container runs as root user, which is a security risk.
The container runs the Node.js server as root by default. If the server is compromised, an attacker gains root privileges inside the container. Add a non-root user and switch to it before running the application.
🔒 Proposed fix to run as non-root user
Note: Port 80 is a privileged port (<1024). If you switch to a non-root user, you'll need to either use a higher port (e.g., 8080) or grant
CAP_NET_BIND_SERVICEcapability.📝 Committable suggestion
🧰 Tools
🪛 Trivy (0.69.3)
[error] 1-1: Image user should not be 'root'
Specify at least 1 USER command in Dockerfile with non-root user as argument
Rule: DS-0002
Learn more
(IaC/Dockerfile)
🤖 Prompt for AI Agents
Source: Linters/SAST tools