Skip to content

Commit

Permalink
Update i18n meta data handling script
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Mar 8, 2022
1 parent eda2326 commit c77ba28
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions i18n.nu
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@

let meta = open 'i18n-meta.json'

# Update issue contents for https://github.com/nushell/nushell.github.io/issues/261
def update-i18n-status [] {

print 'This table holds the overview of the nushell docs writing and translation status. Welcome to participate in the translation of the docs. You can update the `i18n-meta.json` file when you have finished writing or translating the doc. Thanks'
print ''
print '---'
print ''
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
| where type == file && name != README.md
| select name
| update en {|it| get-cell $it.name en } | default en 'In progress'
| update de {|it| get-cell $it.name de } | default de '-'
| update zh-cn {|it| get-cell $it.name zh-cn } | default zh-cn '-'
| update ja {|it| get-cell $it.name ja } | default ja '-'
| update es {|it| get-cell $it.name es } | default es '-'
| update pt-BR {|it| get-cell $it.name pt-BR } | default pt-BR '-'
| update en {|it| get-cell $it.name en }
| update de {|it| get-cell $it.name de }
| update zh-cn {|it| get-cell $it.name zh-cn }
| update ja {|it| get-cell $it.name ja }
| update es {|it| get-cell $it.name es }
| update pt-BR {|it| get-cell $it.name pt-BR }
| to md --pretty

print ''
print 'Possible status values: `-`,`Completed`,`In Progress`,`Being translated by @ABC`'
print $'(char nl)Possible status values: `-`,`Completed`,`In Progress`,`Being translated by @ABC`(char nl)'
}

def get-cell [
name: string
lng: string
] {
($meta | where name == $name | get $lng | get 0)
let match = ($meta | where name == $name)
let cellDefault = if ($lng == 'en') { 'In progress' } else { '-' }
# For newly added docs
if ($match | length) == 0 {
$cellDefault

} else { # For existing docs
let val = ($match | get $lng | get 0)
if ($val | empty?) { $cellDefault } else { $val }
}
}

# Generate or update meta data for docs' translation status
def gen-i18n-meta [] {
ls -s book
| where type == file && name != README.md
| select name
| update en 'In progress'
| update de '-'
| update zh-cn '-'
| update ja '-'
| update es '-'
| update pt-BR '-'
| update en {|it| get-cell $it.name en }
| update de {|it| get-cell $it.name de }
| update zh-cn {|it| get-cell $it.name zh-cn }
| update ja {|it| get-cell $it.name ja }
| update es {|it| get-cell $it.name es }
| update pt-BR {|it| get-cell $it.name pt-BR }
| to json -i 2
| save -r i18n-meta.json
}
Expand Down

0 comments on commit c77ba28

Please sign in to comment.