From 73a239c5c9294f7b4b644d39d14abfb4931eb663 Mon Sep 17 00:00:00 2001 From: hustcer Date: Tue, 11 Apr 2023 15:50:18 +0800 Subject: [PATCH] Fix i18n script for nu v0.78 --- i18n-meta.json | 60 +++++++++++++++++++++++++++++++++++++++++--------- i18n.nu | 56 +++++++++++++++++++++++----------------------- 2 files changed, 79 insertions(+), 37 deletions(-) diff --git a/i18n-meta.json b/i18n-meta.json index 2dd1894a71a..f8611dce3da 100644 --- a/i18n-meta.json +++ b/i18n-meta.json @@ -89,16 +89,6 @@ "es": "-", "pt-BR": "-" }, - { - "name": "command_reference.md", - "en": "Completed", - "zh-CN": "-", - "de": "translated by @sebastian-xyz", - "tr": "-", - "ja": "-", - "es": "-", - "pt-BR": "-" - }, { "name": "command_signature.md", "en": "In progress", @@ -159,6 +149,26 @@ "es": "-", "pt-BR": "-" }, + { + "name": "default_shell.md", + "en": "In progress", + "zh-CN": "-", + "de": "-", + "tr": "-", + "ja": "-", + "es": "-", + "pt-BR": "-" + }, + { + "name": "design_notes.md", + "en": "In progress", + "zh-CN": "-", + "de": "-", + "tr": "-", + "ja": "-", + "es": "-", + "pt-BR": "-" + }, { "name": "environment.md", "en": "Completed", @@ -219,6 +229,16 @@ "es": "-", "pt-BR": "-" }, + { + "name": "how_nushell_code_gets_run.md", + "en": "In progress", + "zh-CN": "-", + "de": "-", + "tr": "-", + "ja": "-", + "es": "-", + "pt-BR": "-" + }, { "name": "installation.md", "en": "Completed", @@ -449,6 +469,16 @@ "es": "-", "pt-BR": "-" }, + { + "name": "standard_library.md", + "en": "In progress", + "zh-CN": "-", + "de": "-", + "tr": "-", + "ja": "-", + "es": "-", + "pt-BR": "-" + }, { "name": "stdout_stderr_exit_codes.md", "en": "Completed", @@ -469,6 +499,16 @@ "es": "-", "pt-BR": "-" }, + { + "name": "testing.md", + "en": "In progress", + "zh-CN": "-", + "de": "-", + "tr": "-", + "ja": "-", + "es": "-", + "pt-BR": "-" + }, { "name": "thinking_in_nu.md", "en": "Completed", diff --git a/i18n.nu b/i18n.nu index 531fe9ad183..2d2cad2a675 100644 --- a/i18n.nu +++ b/i18n.nu @@ -3,7 +3,7 @@ let META_FILE = 'i18n-meta.json' if ($META_FILE | path exists) == false { echo '[]' | save -r $META_FILE } -let meta = open $META_FILE +let meta = (open $META_FILE) # Check if a git repo has the specified ref: could be a branch or tag, etc. def 'has-ref' [ @@ -19,17 +19,20 @@ def update-i18n-status [] { print "The following table holds the overview of the Nushell docs’ writing and translation status. Welcome to participate in the translation of the docs. And please update the `i18n-meta.json` file after you have finished writing or translating the doc. Thanks" print $'(char nl)---(char nl)' - ls -s book/*.md - | where type == file - | select name - | upsert en {|it| get-cell $it.name en } - | upsert zh-CN {|it| get-cell $it.name zh-CN } - | upsert de {|it| get-cell $it.name de } - | upsert tr {|it| get-cell $it.name tr } - | upsert ja {|it| get-cell $it.name ja } - | upsert es {|it| get-cell $it.name es } - | upsert pt-BR {|it| get-cell $it.name pt-BR } - | to md --pretty + let status = ( + ls -s book/*.md + | where type == file + | select name + | upsert en {|it| get-cell $it.name en } + | upsert zh-CN {|it| get-cell $it.name zh-CN } + | upsert de {|it| get-cell $it.name de } + | upsert tr {|it| get-cell $it.name tr } + | upsert ja {|it| get-cell $it.name ja } + | upsert es {|it| get-cell $it.name es } + | upsert pt-BR {|it| get-cell $it.name pt-BR } + | to md --pretty + ) + print $status print $'(char nl)Possible status values: `-`,`Completed`,`In Progress`,`Being translated by @ABC`, `commit_id@author` or simply a COMMIT ID indicate your translation end to.(char nl)' } @@ -122,22 +125,21 @@ def main [ lng?: string # The locale to check outdated: zh-CN, de, etc. ] { let locales = ['zh-cn', 'de', 'tr', 'ja', 'es', 'pt-br'] - - if $task == 'gen' { - gen-i18n-meta - } else if $task == 'update' { - update-i18n-status - } else if $task == 'outdated' { - if ($lng | is-empty) { - $'(ansi r)A locale code required, available locales: ($locales), Please try again!(ansi reset)(char nl)' - exit --now - } - let available = ($lng | str downcase) in $locales - if (not $available) { - $'(ansi r)Unsupported locale, available locales: ($locales), Please try again!(ansi reset)(char nl)' - exit --now + match $task { + 'gen' => { gen-i18n-meta }, + 'update' => { update-i18n-status }, + 'outdated' => { + if ($lng | is-empty) { + print $'(ansi r)A locale code required, available locales: ($locales), Please try again!(ansi reset)(char nl)' + exit --now + } + let available = ($lng | str downcase) in $locales + if (not $available) { + print $'(ansi r)Unsupported locale, available locales: ($locales), Please try again!(ansi reset)(char nl)' + exit --now + } + check-outdated-translation $lng } - check-outdated-translation $lng } }