Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the CLI by integrating internationalization capabilities. It allows the application to present messages in different languages, initially supporting English and Japanese, thereby improving accessibility for a broader user base. The changes involve setting up a new i18n framework, localizing all user-facing text, and ensuring that the build and test processes correctly handle the new language assets. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces internationalization support using Paraglide, which is a great enhancement for the CLI. The changes are well-structured, including the addition of message files for English and Japanese, updates to the build process, and the core logic for locale detection and initialization. The existing codebase has been correctly updated to use the new localized messages, and the new functionality is well-tested. I have one suggestion to improve the maintainability of the locale resolution logic for better scalability in the future.
| import { setLocale } from "./paraglide/runtime.js"; | ||
|
|
||
| export type SupportedLocale = "en" | "ja"; | ||
|
|
||
| const DEFAULT_LOCALE: SupportedLocale = "en"; | ||
|
|
||
| export const m = messages; | ||
|
|
||
| export function resolveSupportedLocale( | ||
| input: string | undefined | ||
| ): SupportedLocale { | ||
| if (!input) { | ||
| return DEFAULT_LOCALE; | ||
| } | ||
|
|
||
| const normalized = input | ||
| .trim() | ||
| .replace(/_/g, "-") | ||
| .replace(/[.:].*$/, "") | ||
| .toLowerCase(); | ||
|
|
||
| return normalized.startsWith("ja") ? "ja" : DEFAULT_LOCALE; | ||
| } |
There was a problem hiding this comment.
This file can be simplified and made more maintainable by leveraging more of the exports from the Paraglide runtime.
- The
SupportedLocaletype andDEFAULT_LOCALEconstant are redundant. Paraglide generates and exports them asLocaleandsourceLocale. - The implementation of
resolveSupportedLocaleis not very scalable as it hardcodes a check for the 'ja' locale. This can be made more maintainable by usingavailableLocalesfrom the Paraglide runtime, which will automatically include any new languages you add to your project.
import {
setLocale,
sourceLocale,
availableLocales,
type Locale,
} from "./paraglide/runtime.js";
export type SupportedLocale = Locale;
const DEFAULT_LOCALE: SupportedLocale = sourceLocale;
export const m = messages;
export function resolveSupportedLocale(
input: string | undefined,
): SupportedLocale {
if (!input) {
return DEFAULT_LOCALE;
}
const normalized = input
.trim()
.replace(/_/g, "-")
.replace(/[.:].*$/, "")
.toLowerCase();
// Find the best match from available locales, preferring more specific matches.
const bestMatch = [...availableLocales]
.sort((a, b) => b.length - a.length)
.find((l) => normalized.startsWith(l));
return bestMatch ?? DEFAULT_LOCALE;
}|
replaced by #64 |
What
Why
os-localewith English fallbackRef