Last active
May 23, 2025 00:50
-
-
Save terasakisatoshi/2ee95e2987eb5b91153201ceda1ef1e5 to your computer and use it in GitHub Desktop.
全パッケージ事前翻訳プロジェクト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @doc Mod.obj を事前に実行することで翻訳をキャッシュする | |
using DotEnv; DotEnv.load!() | |
using DocstringTranslation | |
import ProgressMeter | |
lang = ARGS[1] | |
@info lang | |
@switchlang! lang | |
using Pkg | |
pkg = Symbol(ARGS[2]) | |
@info pkg | |
Pkg.activate(temp=true) | |
Pkg.add(string(pkg)) | |
@info "Translating docstrings in $(pkg)" | |
@eval begin | |
import $(pkg) | |
p = ProgressMeter.Progress(length(collect(names($(pkg))))) | |
Base.Threads.@threads for n in names($(pkg)) | |
if startswith(string(n), "@") | |
mod_dot_macro = Expr( | |
:macrocall, | |
Expr(Symbol("."), pkg, QuoteNode(n)), | |
LineNumberNode(1, nothing) | |
) | |
at_doc_threads = Expr( | |
:macrocall, Symbol("@doc"), LineNumberNode(1, nothing), mod_dot_macro | |
) | |
md = eval(at_doc_threads) | |
else | |
mod_dot_obj = Expr( | |
Symbol("."), pkg, QuoteNode(n), | |
) | |
md = eval(Expr(:macrocall, Symbol("@doc"), LineNumberNode(1, nothing), mod_dot_obj)) | |
end | |
ProgressMeter.next!(p) | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Pkg | |
general_registry = filter(Pkg.Registry.reachable_registries()) do r | |
r.name == "General" | |
end |> only | |
for p in collect(values(general_registry.pkgs)) | |
pkg = Symbol(p.name) | |
if endswith(p.name, "_jll") | |
continue | |
end | |
try | |
run(`julia -t 64 hack.jl ja $(pkg)`) | |
catch e | |
@warn e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment