Skip to content

🌐 [translation-sync] long_run_growth: read mpd2020.xlsx from data-lectures - #285

Merged
mmcky merged 3 commits into
mainfrom
translation-sync-2026-08-06T05-49-02-pr-823
Aug 7, 2026
Merged

mmcky merged 3 commits into
mainfrom
translation-sync-2026-08-06T05-49-02-pr-823

Conversation

@mmcky

@mmcky mmcky commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Automated Translation Sync

This PR contains automated translations from QuantEcon/lecture-python-intro.

Source PR

#823 - long_run_growth: read mpd2020.xlsx from data-lectures

Files Updated

  • ✏️ lectures/long_run_growth.md
  • ✏️ .translate/state/long_run_growth.md.yml

Details

  • Source Language: en
  • Target Language: zh-cn
  • Model: claude-sonnet-5

This PR was created automatically by the translation action.

Copilot AI lite review requested due to automatic review settings August 6, 2026 05:49
@mmcky mmcky added action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-5 | Date: 2026-08-07
Routing: editor — 1 major finding(s); 2 minor finding(s) in gating categories (accuracy/terminology/syntax/diff-check/other); accuracy 8 below floor 9; terminology 7 below floor 9
Shadow gate: would NOT auto-merge (recorded only; no action taken)


📝 Translation Quality

Criterion Score
Accuracy 8/10
Fluency 8/10
Terminology 7/10
Formatting 8/10
Overall 7.8/10

Summary: The 'Setting up' section is generally well translated with fluent, accurate prose, but the translation modifies the underlying code logic (loading country_to_name mapping from an external CSV instead of deriving it from the dataset as in the English source) without adjusting the accompanying explanatory text to match, creating an accuracy mismatch between narrative and code. Minor punctuation and phrasing issues also exist but do not significantly impede understanding. Core prose in the 'Setting up' section is accurately and fluently translated, preserving the meaning of the English source Code comments within the changed section are properly translated into Chinese while preserving code functionality where unchanged Proper use of full-width Chinese punctuation throughout the modified section

Suggestions:

  • [major · accuracy] lectures/long_run_growth.md — ## Setting up (code_to_name mapping): The English source builds code_to_name directly from the Maddison dataset via data[['countrycode', 'country']].drop_duplicates()..., but the Chinese translation replaces this with reading an external file ../lectures/datasets/country_code_cn.csv. This is a substantive deviation from the source that changes the underlying logic/code being described, not just a translation of prose. This shou… → If this change is an intentional localization adaptation, it should be clearly noted as such; otherwise align the code and explanatory text with the source's approach of deriving code_to_name from the dataset itself.
  • [minor · terminology] lectures/long_run_growth.md — ## Setting up, second paragraph: There is a full-width comma followed directly by 'Some dating back...' text with an extra space before '有些' — minor punctuation spacing inconsistency: '相关的历史时间序列、\n有些可以追溯到第一个世纪。' uses a full-width enumeration comma(、)where a full-width comma or period would be more appropriate since this is a clause continuation, not a list. → 相关的历史时间序列,有些可以追溯到第一个世纪。
  • [minor · terminology] lectures/long_run_growth.md — ## Setting up, 'We can build a useful mapping...' sentence: The source sentence 'We can build a useful mapping between country codes and country names in this dataset' is translated as a standalone accurate sentence, but since the underlying code was changed to read from an external CSV rather than building the mapping from the dataset, the translated prose no longer accurately describes what the modified code actually does (it still says '在该数据集中...建立一个有效… → Adjust the prose to match the actual code behavior, e.g., mention that the mapping is loaded from a prepared CSV file, or restore the original code.
  • [minor · fluency] lectures/long_run_growth.md — ## Setting up, first sentence: The phrase '有些可以追溯到第一个世纪' is a literal translation of 'some dating back to the first century' but reads slightly awkwardly; a smoother phrasing would improve fluency. → 其中一些数据可追溯至公元一世纪。

🔍 Diff Quality

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

Summary: The data_url change was correctly synced to the same code cell location in the target document, with no other unintended modifications.


This review was generated automatically by action-translation review mode.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This automated translation-sync PR updates the zh-cn long_run_growth lecture to align with upstream data handling changes, notably switching the Maddison dataset source and adjusting how country-code metadata is derived for plotting.

Changes:

  • Update mpd2020.xlsx download URL to use QuantEcon/data-lectures.
  • Replace country_code_cn.csv-based code_to_name mapping with one derived from the Maddison dataset (currently introduces a runtime incompatibility).
  • Update translation sync state metadata (source SHA, sync date, mode, tool version).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lectures/long_run_growth.md Switches dataset URL and changes code_to_name construction used by later plots/labels.
.translate/state/long_run_growth.md.yml Updates translation-sync bookkeeping metadata for this file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lectures/long_run_growth.md Outdated
Comment on lines +141 to +142
code_to_name = data[
['countrycode', 'country']].drop_duplicates().reset_index(drop=True).set_index(['countrycode'])
@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for playful-platypus-17d3bb ready!

Name Link
🔨 Latest commit c0b1761
🔍 Latest deploy log https://app.netlify.com/projects/playful-platypus-17d3bb/deploys/6a7555338d30f10009b0c085
😎 Deploy Preview https://deploy-preview-285--playful-platypus-17d3bb.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

The sync correctly repointed data_url to data-lectures, but it also replaced
a deliberate localisation in the same cell:

  code_to_name = pd.read_csv("../lectures/datasets/country_code_cn.csv")
                   .set_index('code')

with the English source's version, which derives the mapping from the
spreadsheet's own countrycode/country columns. That drops the name_chinese
column, and long_run_growth.md:263 reads code_to_name.loc[c]['name_chinese'],
so the build failed with KeyError: 'name_chinese'. Nine call sites use
code_to_name, and the comment at :536 relies on country_code_cn.csv carrying
the BEM mapping.

Had it built, every chart in this lecture would have silently reverted to
English country labels on the Chinese site.

This restores only that line. The repoint — the point of the sync — is
untouched, so mpd2020.xlsx still comes from data-lectures rather than from
lecture-python-intro, where it no longer exists.

Verified: mpd2020.xlsx loads from the new URL (21,682 rows) and
code_to_name.loc['GBR']['name_chinese'] resolves to 英国.

Context: QuantEcon/workspace-lectures#25.
@mmcky

mmcky commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

The failing build was catching a real problem, not flaking. Pushed c0b1761 to fix it.

What was wrong

This sync changed two things in the same cell. The first is the point of the PR and is correct — data_url moves to data-lectures, which it has to, because mpd2020.xlsx no longer exists in lecture-python-intro. The second was collateral:

Before code_to_name = pd.read_csv("../lectures/datasets/country_code_cn.csv").set_index('code')
Sync replaced it with code_to_name = data[['countrycode', 'country']].drop_duplicates()…

That second line is the English source's version, which derives the mapping from the spreadsheet's own countrycode/country columns. This repo instead loads country_code_cn.csv, a local file mapping codes to Chinese names — ARG,Argentina,阿根廷. Replacing it drops the name_chinese column, and long_run_growth.md:263 does code_to_name.loc[c]['name_chinese'], hence KeyError: 'name_chinese'.

Nine call sites use code_to_name, and the comment at :536 explicitly relies on country_code_cn.csv carrying the BEM mapping. Had this built green, every chart in the lecture would have silently reverted to English country labels on the Chinese site — so the failure was the good outcome.

The fix

One line restored. The diff against main is now the repoint alone.

Verified directly rather than by re-running the build: mpd2020.xlsx loads from the new data-lectures URL (21,682 rows, matching upstream), and code_to_name.loc['GBR']['name_chinese'] resolves to 英国.

Why this one and not the others

#286 and #288 touched only URL lines and merged cleanly. This PR is different because the English side changed a line adjacent to a localised one inside the same code cell, and the sync replaced the whole block.

Worth noting for the translation programme: that is a general hazard for the rest of the dataset migration, not a one-off. Any lecture where this repo has localised a line near a data read will collide the same way, and it surfaces only as a build failure — there is no check that says "a localisation was overwritten". Recorded in QuantEcon/workspace-lectures#25.

Merging this closes the last of the eight datasets that were 404ing on this repo's main.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 7, 2026 03:52 Inactive
@mmcky
mmcky merged commit 4e82840 into main Aug 7, 2026
8 checks passed
@mmcky
mmcky deleted the translation-sync-2026-08-06T05-49-02-pr-823 branch August 7, 2026 03:55
mmcky added a commit that referenced this pull request Aug 11, 2026
#291)

These are lines whose Chinese content lives inside a code cell, where a
whole-cell resync can drop it without anything raising. They are the cells
an upcoming repoint rewrites, so mark them before that lands rather than
after.

The dangerous three are executable, not comments:

  heavy_tails.md:815  label="公司规模(市值)"
  heavy_tails.md:868  country_names = ['美国', '日本', '印度', '意大利']
  heavy_tails.md:882  ... label=country_names[i], xlabel='对数财富' ...

:868 defines and :882 consumes, inside the same cell, so a wholesale
replacement drops both together and the cell still runs — English labels
just appear on the Chinese charts. That is silent, unlike the KeyError in
#285 where only one half went.

The other four are translated comments (heavy_tails 816, 837, 878 and
mle 109).

What this does and does not buy. `# i18n` is named in action-translation's
translation prompts (src/translator.ts:291, :384, :666 — "NEVER remove
i18n/localization code ... or lines marked `# i18n`"), and the tool emits it
on the font block it injects (src/localization-rules.ts:151-154). So it is a
live convention, not decoration. But it is *prompt-level* protection: the
extract-and-reinject phase that would make it deterministic is still a
proposal (docs/developer/roadmap.md, "i18n code annotation convention",
phase 2), and that roadmap entry exists precisely because the model
sometimes drops these lines anyway. Markers raise the odds; hand-diffing
each sync PR is still what actually protects these lines.

Three more lines in these cells are localised and deliberately NOT marked --
the `caption:` keys at heavy_tails.md:807, 833 and 859. They sit in the
cell's mystnb YAML header, where `#` is not a comment marker and the
convention has no meaning. They are on the hand-diff list instead.

Repo-wide this takes lecture-intro.zh-cn from 0 markers to 7; the same
convention has 132 uses in lecture-python.zh-cn. Trailing two-space form
matches that repo.

Verified: diff is 7 lines, all pure appends; no data-read URL and no YAML
key touched; every code cell in both files still compiles, apart from the
pre-existing `!pip install` magic cell at heavy_tails.md:48.

Step C0 of QuantEcon/workspace-lectures#23. See QuantEcon/workspace-lectures#26

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants