From 4d0eda2a46bce031b92b6d504a7ac2a52ac4912e Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Thu, 6 Jun 2024 12:02:39 -0400 Subject: [PATCH 1/2] [i18n & CI] Add default_lang_commit to front matter --- content/ja/_index.md | 1 + content/zh/_index.md | 1 + content/zh/docs/_index.md | 1 + content/zh/docs/concepts/_index.md | 1 + content/zh/docs/concepts/components.md | 1 + .../zh/docs/concepts/context-propagation.md | 1 + .../zh/docs/concepts/semantic-conventions.md | 1 + content/zh/docs/demo/_index.md | 1 + content/zh/docs/kubernetes/_index.md | 1 + content/zh/docs/what-is-opentelemetry.md | 1 + scripts/i18n-check.sh | 75 ++++++++++++++----- 11 files changed, 68 insertions(+), 17 deletions(-) diff --git a/content/ja/_index.md b/content/ja/_index.md index d9d4935368de..3e3ddc362b9a 100644 --- a/content/ja/_index.md +++ b/content/ja/_index.md @@ -4,6 +4,7 @@ description: >- 効果的な観測を可能にする、高品質でユビキタスかつポータブルなテレメトリー developer_note: blocks/coverコラム(以下で使用)は、ファイル名に "background" を含む画像ファイルを背景画像として使用します。 +default_lang_commit: 902043db ---
diff --git a/content/zh/_index.md b/content/zh/_index.md index e1232663cb67..a07cf2e408c9 100644 --- a/content/zh/_index.md +++ b/content/zh/_index.md @@ -6,6 +6,7 @@ show_banner: true developer_note: 下文所用的 blocks/cover 短代码将使用文件名中包含 "background" 的图像文件作为背景图。 +default_lang_commit: 6e35a949 ---
diff --git a/content/zh/docs/_index.md b/content/zh/docs/_index.md index d256b22cd44e..f4017bf2fc13 100644 --- a/content/zh/docs/_index.md +++ b/content/zh/docs/_index.md @@ -1,6 +1,7 @@ --- title: 文档 menu: { main: { weight: 10 } } +default_lang_commit: 6e35a949 --- OpenTelemetry 也被称为 OTel,是一个供应商中立的、开源的[可观测性](concepts/observability-primer/#what-is-observability)框架, diff --git a/content/zh/docs/concepts/_index.md b/content/zh/docs/concepts/_index.md index 5fa4f7a6b9fa..d1bf111ed97f 100644 --- a/content/zh/docs/concepts/_index.md +++ b/content/zh/docs/concepts/_index.md @@ -4,6 +4,7 @@ linkTitle: 概念 description: OpenTelemetry 核心概念 aliases: [concepts/overview] weight: 170 +default_lang_commit: d638c386 --- 在本节中,你将了解 OpenTelemetry 项目的数据来源和关键组件。 diff --git a/content/zh/docs/concepts/components.md b/content/zh/docs/concepts/components.md index a713930ae109..01dfc25a8885 100644 --- a/content/zh/docs/concepts/components.md +++ b/content/zh/docs/concepts/components.md @@ -3,6 +3,7 @@ title: 组件 description: 构成 OpenTelemetry 的主要组件 aliases: [data-collection] weight: 20 +default_lang_commit: 1ca30b4d --- OpenTelemetry 项目目前由以下几个主要部分构成: diff --git a/content/zh/docs/concepts/context-propagation.md b/content/zh/docs/concepts/context-propagation.md index a2e350c8aab4..2f5ad0d54e2c 100644 --- a/content/zh/docs/concepts/context-propagation.md +++ b/content/zh/docs/concepts/context-propagation.md @@ -2,6 +2,7 @@ title: 上下文传播 weight: 10 description: 了解实现分布式追踪的概念。 +default_lang_commit: 7bb7dbb6 --- 通过上下文传播,[信号](/docs/concepts/signals)可以相互关联, diff --git a/content/zh/docs/concepts/semantic-conventions.md b/content/zh/docs/concepts/semantic-conventions.md index 9c97d66d1fb7..1f0c397d5aeb 100644 --- a/content/zh/docs/concepts/semantic-conventions.md +++ b/content/zh/docs/concepts/semantic-conventions.md @@ -2,6 +2,7 @@ title: 语义约定 description: 不同类型的操作和数据的通用名称。 weight: 30 +default_lang_commit: 1d9a1df8 --- OpenTelemetry 定义了[语义约定](/docs/specs/semconv/), diff --git a/content/zh/docs/demo/_index.md b/content/zh/docs/demo/_index.md index eb271fbbef6e..ef6b4eb31d26 100644 --- a/content/zh/docs/demo/_index.md +++ b/content/zh/docs/demo/_index.md @@ -5,6 +5,7 @@ cascade: repo: https://github.com/open-telemetry/opentelemetry-demo weight: 2 cSpell:ignore: OLJCESPC +default_lang_commit: 1d9a1df8 --- 欢迎使用 [OpenTelemetry 演示](/ecosystem/demo/)文档, diff --git a/content/zh/docs/kubernetes/_index.md b/content/zh/docs/kubernetes/_index.md index abc95817f1be..cd636ecc09dc 100644 --- a/content/zh/docs/kubernetes/_index.md +++ b/content/zh/docs/kubernetes/_index.md @@ -3,6 +3,7 @@ title: 使用 Kubernetes 部署 OpenTelemetry linkTitle: Kubernetes weight: 11 description: Using OpenTelemetry with Kubernetes +default_lang_commit: 1d9a1df8 --- ## 介绍 diff --git a/content/zh/docs/what-is-opentelemetry.md b/content/zh/docs/what-is-opentelemetry.md index 4fe615c70b64..9f4d28ff5d45 100644 --- a/content/zh/docs/what-is-opentelemetry.md +++ b/content/zh/docs/what-is-opentelemetry.md @@ -2,6 +2,7 @@ title: 什么是 OpenTelemetry? description: 简短说明 OpenTelemetry 是什么,不是什么。 weight: 150 +default_lang_commit: d638c386 --- OpenTelemetry diff --git a/scripts/i18n-check.sh b/scripts/i18n-check.sh index 29b633a4f8c7..e09680d9c380 100755 --- a/scripts/i18n-check.sh +++ b/scripts/i18n-check.sh @@ -2,12 +2,17 @@ # # Inspired by https://github.com/kubernetes/website/blob/main/scripts/lsync.sh +DEFAULT_LANG="en" +DEFAULT_TARGET="content" EXTRA_DIFF_ARGS="--numstat" +FLAG_UPDATE="" +FLAG_VERBOSE="" +I18N_DLC_KEY="default_lang_commit" TARGET_PATHS="" function _usage() { cat <&2 - usage 1 - fi - TARGET_PATHS="$@" + if [[ -z "$TARGET_PATHS" ]]; then + TARGET_PATHS="$DEFAULT_TARGET" + if [[ -n $FLAG_VERBOSE ]]; then echo "INFO: using default target path: $TARGET_PATHS"; fi + fi + if [[ -f "TARGET_PATHS" && ! -e "$TARGET_PATHS" ]] ; then echo "Path not found: '$TARGET_PATHS'" >&2 exit 2 fi } +function update_i18n_hash() { + # Usage: update_i18n_hash + # + # Adds to or updates the file's front matter's field + # $I18N_DLC_KEY with value . + + local LASTCOMMIT="$1" + local f="$2" + + if grep -q "^$I18N_DLC_KEY:" "$f"; then + perl -i -pe "s/(^$I18N_DLC_KEY):.*/\$1: $LASTCOMMIT/" "$f" + else + perl -i -0777 -pe "s/^(---.*?)(\n---\n)/\$1\n$I18N_DLC_KEY: $LASTCOMMIT\$2/sm" "$f" + fi + if [[ -n $FLAG_VERBOSE ]]; then + echo -e "i18n commit ID\t$f $LASTCOMMIT - updated" + fi +} + function main() { process_CLI_args "$@" if [ -f "$TARGET_PATHS" ] ; then TARGETS="$TARGET_PATHS" else - TARGETS=$(find $TARGET_PATHS -name "*.md") + TARGETS=$(find $TARGET_PATHS -name "*.md" -not -path "*/$DEFAULT_LANG/*") if [[ -z "$TARGETS" ]]; then echo "ERROR: target directory contains no markdown files: '$TARGET_PATHS'" >&2 exit 1 fi - # if [[ -n $VERBOSE ]]; then echo -e "All targets: $TARGETS"; fi + # if [[ -n $FLAG_VERBOSE ]]; then echo -e "All targets: $TARGETS"; fi fi SYNCED=1 for f in $TARGETS; do - # if [[ -n $VERBOSE ]]; then echo -e "Checking\t$f"; fi + # if [[ -n $FLAG_VERBOSE ]]; then echo -e "Checking\t$f"; fi EN_VERSION=$(echo "$f" | sed "s/content\/.\{2,5\}\//content\/en\//g") + + # Try to get commit ref from file front matter + LASTCOMMIT=$(perl -ne "print \"\$1\" if /^$I18N_DLC_KEY:\\s*(.*)/" "$f") + if [[ -z $LASTCOMMIT ]]; then + # Get commit hash from git commit info + LASTCOMMIT=$(git log -n 1 --pretty=format:%h -- "$f") + fi + + if [[ -n $FLAG_UPDATE ]]; then + update_i18n_hash "$LASTCOMMIT" "$f" + fi + if [[ ! -e "$EN_VERSION" ]]; then - echo "Base file renamed or removed: $EN_VERSION" + echo -e "File not found\t$EN_VERSION - $f - $DEFAULT_LANG was removed or renamed" SYNCED=0 continue fi - LASTCOMMIT=$(git log -n 1 --pretty=format:%h -- "$f") - git diff --exit-code $EXTRA_DIFF_ARGS $LASTCOMMIT...HEAD "$EN_VERSION" - if [ $? -ne 0 ] ; then + DIFF=$(git diff --exit-code $EXTRA_DIFF_ARGS $LASTCOMMIT...HEAD "$EN_VERSION") + if [[ -n "$DIFF" ]]; then # [[ $? -ne 0 ]] + echo "$DIFF - $f" SYNCED=0 - elif [[ -n $VERBOSE ]]; then + elif [[ -n $FLAG_VERBOSE ]]; then echo -e "File is in sync\t$f" fi done From c7a19e03c85c10c0b66b8ea542a7c17a455efba8 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Thu, 6 Jun 2024 12:14:39 -0400 Subject: [PATCH 2/2] Use base commit iDs --- content/zh/docs/concepts/semantic-conventions.md | 2 +- content/zh/docs/demo/_index.md | 2 +- content/zh/docs/kubernetes/_index.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/zh/docs/concepts/semantic-conventions.md b/content/zh/docs/concepts/semantic-conventions.md index 1f0c397d5aeb..33b732b6d51b 100644 --- a/content/zh/docs/concepts/semantic-conventions.md +++ b/content/zh/docs/concepts/semantic-conventions.md @@ -2,7 +2,7 @@ title: 语义约定 description: 不同类型的操作和数据的通用名称。 weight: 30 -default_lang_commit: 1d9a1df8 +default_lang_commit: 71d813acaa3dcb7d8ae3f96451406276f84242f4 --- OpenTelemetry 定义了[语义约定](/docs/specs/semconv/), diff --git a/content/zh/docs/demo/_index.md b/content/zh/docs/demo/_index.md index ef6b4eb31d26..ad76b124e689 100644 --- a/content/zh/docs/demo/_index.md +++ b/content/zh/docs/demo/_index.md @@ -5,7 +5,7 @@ cascade: repo: https://github.com/open-telemetry/opentelemetry-demo weight: 2 cSpell:ignore: OLJCESPC -default_lang_commit: 1d9a1df8 +default_lang_commit: b7ee690154aacc8d6e43636af00743994fb6dc27 --- 欢迎使用 [OpenTelemetry 演示](/ecosystem/demo/)文档, diff --git a/content/zh/docs/kubernetes/_index.md b/content/zh/docs/kubernetes/_index.md index cd636ecc09dc..86724925e85e 100644 --- a/content/zh/docs/kubernetes/_index.md +++ b/content/zh/docs/kubernetes/_index.md @@ -3,7 +3,7 @@ title: 使用 Kubernetes 部署 OpenTelemetry linkTitle: Kubernetes weight: 11 description: Using OpenTelemetry with Kubernetes -default_lang_commit: 1d9a1df8 +default_lang_commit: 54bc7873eaf53af1314feef7f91797d5d261a57b --- ## 介绍