查看“︁Tc”︁的源代码
←
Tc
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{nB|This has been superseded by '''[[oc|{{spmono|oc}}]]''' on Windows.}} A tiny little python script used for the conversion of filenames into traditional Chinese and, for supported filetypes, the conversion of the contents of files into traditional Chinese at the user’s direction. Apart from python itself, on Linux, {{spmono|pip}} needs to be installed separately through <syntaxhighlight lang="bash" inline>sudo apt install python3-pip</syntaxhighlight>, and then {{spmono|open<wbr />cc}} needs to be installed via {{spmono|pip}} by <syntaxhighlight lang="bash" inline>pip install opencc --break-system-packages</syntaxhighlight>; on Windows, {{spmono|pip}} is automatically installed with python installation, but you may have to use {{spmono|open<wbr />cc<wbr />-<wbr />py<wbr />thon<wbr />-<wbr />re<wbr />im<wbr />ple<wbr />ment<wbr />ed}} instead of the official {{spmono|open<wbr />cc}} if obstacles encountered while installing the latter. By default, the script will rename the designated file or files into traditional Chinese, and for supported filetypes, to wit, .{{spmono|ass}}, .{{spmono|css}}, .{{spmono|htm}}, .{{spmono|html}}, .{{spmono|md}}, .{{spmono|shtm}}, .{{spmono|shtml}}, .{{spmono|srt}}, .{{spmono|txt}}, .{{spmono|vtt}}, .{{spmono|wiki}}, .{{spmono|xht}}, .{{spmono|xhtml}}, and .{{spmono|xml}} files, if <code>'''-c'''</code> switch is passed to the script, then copies of the files with their contents also converted into traditional Chinese will be saved alongside the originals with a suffix ‘{{spmono|_t}}’ appended to their filenames. The reversed conversion can be triggered with the <code>'''-s'''</code> switch, where in this case, the suffix appended to the filenames will correspondingly change to ‘{{spmono|_s}}’. Due to python’s independent and yet also inscrutable way of dealing with the paths, its processing logic becomes funny and somewhat risky when pure path or paths are given to the script— * if a path ends with a backslash <code>\</code> (or a slash <code>/</code> on Linux) is given to the script, then no conversion will be done at all; * if an asterisk <code>*</code> mark is added to a path ending with a backslash <code>\</code> (or a slash <code>/</code> on Linux) and passed to the script, then all the files under the given path but not with its subfolders will be renamed; <br />(the asterisk <code>*</code> mark could also work as a wildcard but, in that way, the script shall perform in a logic with which we are all familiar;) * if a path is given ''without'' ending with a backslash <code>\</code> (or a slash <code>/</code> on Linux), then the script shall convert all the names of the files, ''and'' all the names of the subfolders under the given path; * an optional <code>'''-d'''</code> switch is added specifically for the preceding instance—if used, the script will then rename the terminal directory only, not any of its files or subfolders; and * an optional <code>'''-r'''</code> switch is added to rename recursively, but it is vulnerable and only partially effective when no <code>-d</code> switch is given, the path is given ''without'' ending with a backslash <code>\</code> (or a slash <code>/</code> on Linux), and the subfolders themselves need no conversion. These rules above also apply to the conversion of contents for supported filetypes when <code>-c</code> is used. The current state of the script in dealing with paths is clearly not entirely satisfactory, and yet that is what I can achieve for now. There is also a {{spmono|REG}} file attached below to add some commonly used conversion commands to the shell, which, obviously, only works on Windows. A little note is that the asymmetrical selection of conversion tables ‘{{spmono|'''s2twp'''}}’ and ‘{{spmono|'''t2s'''}}’ is on (my personal) purpose, not an error; feel free to change them at your desire. ==The python script== {{tc.py}} ==The wrappers== {{upw-win|tc}} {{upw-linux|tc}} ==The {{spmono|REG}} file== {{tc-reg}} __NOTOC__ {{DISPLAYTITLE:{{spmono|tc}}}}
此页面嵌入的页面:
Template:NB
(
查看源代码
)
Template:Spmono
(
查看源代码
)
Template:Stblu
(
查看源代码
)
Template:Stppl
(
查看源代码
)
Template:Stsbg
(
查看源代码
)
Template:Stsbl
(
查看源代码
)
Template:Tc-reg
(
查看源代码
)
Template:Tc.py
(
查看源代码
)
Template:Upw-linux
(
查看源代码
)
Template:Upw-win
(
查看源代码
)
返回
Tc
。
导航菜单
个人工具
登录
命名空间
页面
讨论
不转换
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
臺灣正體
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息