Skip to content

feat(scripts): add internationalization support to quickstart script#6

Merged
qychen2001 merged 1 commit intopoco-ai:mainfrom
blogding:feat/quickstart-i18n
Feb 5, 2026
Merged

feat(scripts): add internationalization support to quickstart script#6
qychen2001 merged 1 commit intopoco-ai:mainfrom
blogding:feat/quickstart-i18n

Conversation

@blogding
Copy link

@blogding blogding commented Feb 5, 2026

Add bilingual support (English and Chinese) to the quickstart.sh script to improve accessibility for Chinese-speaking users.

Changes:

  • Add LANG variable to control language setting (en or zh)
  • Implement msg() function for message localization
  • Add select_language() interactive language selection
  • Localize all user-facing messages, prompts, and help text
  • Add --lang CLI option to set language preference
  • Update usage examples to show language selection

The script now defaults to English but allows users to select Chinese through an interactive prompt or via the --lang flag.

Summary by CodeRabbit

  • New Features
    • Added multilingual support for English and Chinese languages.
    • Users can now select their preferred language during interactive setup.
    • All user-facing text, prompts, error messages, and help documentation are now localized.

Add bilingual support (English and Chinese) to the quickstart.sh script to improve accessibility for Chinese-speaking users.

Changes:
- Add LANG variable to control language setting (en or zh)
- Implement msg() function for message localization
- Add select_language() interactive language selection
- Localize all user-facing messages, prompts, and help text
- Add --lang CLI option to set language preference
- Update usage examples to show language selection

The script now defaults to English but allows users to select Chinese through an interactive prompt or via the --lang flag.
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

 ______________________________________________________________________________________________________
< What one programmer can do in one month, two programmers can do in two months. - Frederick P. Brooks >
 ------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

✏️ Tip: You can disable in-progress messages and the fortune message in your review settings.

Tip

You can disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting in your project's settings in CodeRabbit to disable sequence diagrams in the walkthrough.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qychen2001
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9450ca62f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +815 to +816
if [[ "$INTERACTIVE" = true ]] && [[ "$LANG" == "en" ]]; then
select_language

Choose a reason for hiding this comment

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

P2 Badge Skip language prompt when --lang is explicitly set

In interactive terminals, passing --lang en still triggers select_language, because the guard only checks LANG == "en" and cannot distinguish the default from an explicit CLI choice. This makes the new --lang flag non-deterministic for English users (they are prompted again and can accidentally switch languages), which contradicts the option’s documented behavior as a direct language setting.

Useful? React with 👍 / 👎.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds internationalization support to the quickstart.sh script, enabling bilingual operation in English and Chinese. The implementation introduces a localization framework through a msg() function that returns language-specific strings based on a LANG variable, and adds an interactive language selection feature at script startup.

Changes:

  • Implements a msg() localization function with 80+ message keys for all user-facing text
  • Adds select_language() function for interactive language selection at script startup
  • Introduces --lang CLI flag to set language preference (en or zh)
  • Translates all user-facing messages, prompts, help text, and success/error messages

Comment on lines +815 to +817
if [[ "$INTERACTIVE" = true ]] && [[ "$LANG" == "en" ]]; then
select_language
fi
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The language selection logic only triggers when LANG == "en" (the default). This means if a user explicitly sets --lang zh on the command line, and the script is in interactive mode, the select_language() prompt won't appear (which is correct). However, if the user's system has LANG environment variable set to something other than "en" (which is common), this script's LANG variable will be overridden by the system's LANG variable, and the language selection won't trigger.

This is another consequence of using the LANG variable name, which conflicts with the system environment variable. Once the variable is renamed (as suggested in the previous comment), this logic should work correctly.

Copilot uses AI. Check for mistakes.
ANTHROPIC_KEY="$2"; shift 2 ;;
--openai-key)
OPENAI_KEY="$2"; shift 2 ;;
--lang)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The --lang argument accepts any value without validation. If a user provides an invalid language code (e.g., --lang fr or --lang invalid), the script will silently accept it and use English as the fallback in all msg() calls, which could be confusing.

Consider adding validation to ensure only "en" or "zh" are accepted, with a clear error message if an invalid value is provided. For example:

--lang)
  if [[ "$2" != "en" && "$2" != "zh" ]]; then
    print_error "Invalid language: $2. Supported languages: en, zh"
    exit 1
  fi
  LANG="$2"; shift 2 ;;
Suggested change
--lang)
--lang)
if [[ "$2" != "en" && "$2" != "zh" ]]; then
print_error "Invalid language: $2. Supported languages: en, zh"
exit 1
fi

Copilot uses AI. Check for mistakes.

print_header "S3 Public Endpoint Configuration" >&2
cat >&2 <<'EOF'
print_header "$(msg "header.s3_endpoint")" >&2
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The print_header function is being called with $(msg "header.s3_endpoint") wrapped in double quotes as an argument. However, command substitution with $(...) is already being used, so this will execute msg "header.s3_endpoint" and pass the result to print_header.

The issue is that this creates an extra subshell execution during command substitution. While this works, it's inefficient and inconsistent. Consider passing the message key directly and having print_header call msg(), or at minimum, remove the unnecessary double quotes around the command substitution since it's already properly quoted.

Copilot uses AI. Check for mistakes.
Comment on lines +528 to +532
if [[ "$LANG" == "zh" ]]; then
print_info "跳过 S3 公共端点(本地开发模式)" >&2
else
print_info "Skipping S3 public endpoint (local development mode)" >&2
fi
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

These hardcoded localized messages are inconsistent with the msg() function pattern used elsewhere in the script. The message "跳过 S3 公共端点(本地开发模式)" / "Skipping S3 public endpoint (local development mode)" should be defined in the msg() function and called using a message key for consistency.

This would make the code more maintainable and easier to update translations in the future. Consider adding a message key like "info.skipping_s3_endpoint" to the msg() function and using it here.

Suggested change
if [[ "$LANG" == "zh" ]]; then
print_info "跳过 S3 公共端点(本地开发模式)" >&2
else
print_info "Skipping S3 public endpoint (local development mode)" >&2
fi
print_info "$(msg "info.skipping_s3_endpoint")" >&2

Copilot uses AI. Check for mistakes.
Comment on lines +986 to 1016
if [[ "$LANG" == "zh" ]]; then
echo " 如果您想使用 GPT 模型,可以稍后在 .env 中添加"
else
echo " Add it later in .env if you want to use GPT models"
fi
fi

echo ""
print_success "Bootstrap completed!"
print_success "$(msg "success.bootstrap")"
echo ""
echo "Next steps:"
echo " 1. Make sure ANTHROPIC_AUTH_TOKEN is set in .env"
if [[ "$START_ALL" = true ]]; then
echo " 2. Open browser: http://localhost:3000"
echo " 3. View logs: docker compose logs -f backend executor-manager frontend"
if [[ "$LANG" == "zh" ]]; then
echo "后续步骤:"
echo " 1. 确保在 .env 中设置了 ANTHROPIC_AUTH_TOKEN"
if [[ "$START_ALL" = true ]]; then
echo " 2. 打开浏览器: http://localhost:3000"
echo " 3. 查看日志: docker compose logs -f backend executor-manager frontend"
else
echo " 2. 启动服务: docker compose up -d"
echo " 3. 打开浏览器: http://localhost:3000"
fi
else
echo " 2. Start services: docker compose up -d"
echo " 3. Open browser: http://localhost:3000"
echo "Next steps:"
echo " 1. Make sure ANTHROPIC_AUTH_TOKEN is set in .env"
if [[ "$START_ALL" = true ]]; then
echo " 2. Open browser: http://localhost:3000"
echo " 3. View logs: docker compose logs -f backend executor-manager frontend"
else
echo " 2. Start services: docker compose up -d"
echo " 3. Open browser: http://localhost:3000"
fi
fi
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

These hardcoded localized messages are inconsistent with the msg() function pattern used elsewhere in the script. Messages like "如果您想使用 GPT 模型,可以稍后在 .env 中添加" / "Add it later in .env if you want to use GPT models" should be defined in the msg() function for consistency.

Similarly, the "Next steps" section (lines 996-1016) contains multiple hardcoded messages that should be centralized in the msg() function. This would improve maintainability and make it easier to update translations in the future.

Copilot uses AI. Check for mistakes.
Comment on lines +329 to +333
# 将空值视为"未设置"
if [[ -z "$value" ]]; then
return 1
fi
# Treat example placeholders as "not set".
# 将示例占位符视为"未设置"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

Code comments have been changed from English to Chinese. This is inconsistent with typical open-source project conventions where code comments are generally kept in English to ensure all contributors can understand the codebase, regardless of which languages the UI supports.

User-facing messages should be localized, but internal code comments and documentation should remain in English for maintainability and accessibility to the broader developer community.

Copilot uses AI. Check for mistakes.
Comment on lines +354 to +358
# 修复: 改进逻辑以允许在值不同时覆盖
if [[ "$FORCE_ENV" = false ]]; then
local existing_value
existing_value="$(read_env_key "$key" || true)"
# Only skip if the value is EXACTLY the same as what we are trying to write
# 仅当值完全相同时才跳过
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

Code comments have been changed from English to Chinese. This is inconsistent with typical open-source project conventions where code comments are generally kept in English to ensure all contributors can understand the codebase, regardless of which languages the UI supports.

User-facing messages should be localized, but internal code comments and documentation should remain in English for maintainability and accessibility to the broader developer community.

Copilot uses AI. Check for mistakes.
Comment on lines +394 to +399
# 修复: 移除了 "保留当前值? [Y/n]" 逻辑
# 改为使用标准的默认值提示样式

local display_default=""
if [[ -n "$current_value" ]]; then
# Mask the key for display
# 为显示掩码密钥
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

Code comments have been changed from English to Chinese. This is inconsistent with typical open-source project conventions where code comments are generally kept in English to ensure all contributors can understand the codebase, regardless of which languages the UI supports.

User-facing messages should be localized, but internal code comments and documentation should remain in English for maintainability and accessibility to the broader developer community.

Copilot uses AI. Check for mistakes.
Comment on lines 804 to 805
-h|--help)
usage; exit 0 ;;
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The --help flag is processed after the --lang flag in the argument parsing loop. However, the usage() function that is called by --help uses the msg() function which depends on the LANG variable. This creates a potential issue: if a user runs ./scripts/quickstart.sh --help --lang zh, the help text will be shown in English (the default) because --help exits before --lang is processed.

To fix this, the --lang argument should be processed before calling usage(), or the usage() function call should be deferred until after all arguments are parsed. Alternatively, add a note in the documentation that --lang should be specified before --help.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +42
# Language setting (en or zh)
LANG="en"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The variable name LANG conflicts with a standard environment variable used by the system for locale settings. Using LANG can cause unexpected behavior as it may override or be overridden by the system's locale configuration. This could affect how various commands (like date, sort, etc.) behave within the script.

Consider renaming this variable to something more specific like UI_LANG, SCRIPT_LANG, or POCO_LANG to avoid conflicts with the system environment variable.

Suggested change
# Language setting (en or zh)
LANG="en"
# Script message language setting (en or zh). Do not override system $LANG.
SCRIPT_LANG="${SCRIPT_LANG:-en}"

Copilot uses AI. Check for mistakes.
@qychen2001 qychen2001 merged commit d8153f1 into poco-ai:main Feb 5, 2026
6 of 7 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