<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wang/Zuomeng on Medium]]></title>
        <description><![CDATA[Stories by Wang/Zuomeng on Medium]]></description>
        <link>https://medium.com/@wangzuomeng?source=rss-71b793ad3911------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Uw5_Hk7cbQNBhBde</url>
            <title>Stories by Wang/Zuomeng on Medium</title>
            <link>https://medium.com/@wangzuomeng?source=rss-71b793ad3911------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:27:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wangzuomeng/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to localize vscode extension]]></title>
            <link>https://medium.com/@wangzuomeng/localize-vscode-extension-69cd16bbf115?source=rss-71b793ad3911------2</link>
            <guid isPermaLink="false">https://medium.com/p/69cd16bbf115</guid>
            <category><![CDATA[i18n]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[l10n]]></category>
            <dc:creator><![CDATA[Wang/Zuomeng]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 15:22:06 GMT</pubDate>
            <atom:updated>2025-05-14T07:59:03.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2dIEZaO8p3PdjU4WNc0eoQ.jpeg" /><figcaption>Pexels Kevin Ku: <a href="https://www.pexels.com/zh-cn/photo/577585/">https://www.pexels.com/zh-cn/photo/577585/</a></figcaption></figure><p>Recently, I’m writing a vscode extension. But I cannot find how to localize it. It is really hard to find an example. Thanks for the answer <a href="https://stackoverflow.com/questions/56420338/how-to-localise-vscode-extension">https://stackoverflow.com/questions/56420338/how-to-localise-vscode-extension</a></p><p>If you want to localize your extension, there are three parts you should consider:</p><ul><li>package.json</li><li>main process</li><li>web-view content</li></ul><h4>Localize package.json</h4><p>Here is a example package.json :</p><pre>{<br>  &quot;contributes&quot;: {<br>    &quot;commands&quot;: [<br>      {<br>        &quot;command&quot;: &quot;example.nls&quot;,<br>        &quot;title&quot;: &quot;Example nls&quot;<br>      }<br>    ]<br>  }<br>}</pre><p>First, create a localized file package.nls.json :</p><pre>{<br>  &quot;Example nls&quot;: &quot;Example nls&quot;<br>}</pre><p>Then, create a target locale file package.nls.zh-cn.json :</p><pre>{<br>  &quot;Example nls&quot;: &quot;nls 示例&quot;<br>}</pre><p>Finally, edit the package.json :</p><pre>{<br>  &quot;contributes&quot;: {<br>    &quot;commands&quot;: [<br>      {<br>        &quot;command&quot;: &quot;example.nls&quot;,<br>        &quot;title&quot;: &quot;%Example nls%&quot;<br>      }<br>    ]<br>  }<br>}</pre><h4>Localize for main process</h4><p>First, create localized file l10n/bundle.zh-cn.json :</p><pre>{<br>  &quot;Hello&quot;: &quot;你好&quot;<br>}</pre><p>Then, add l10n attribute in package.json :</p><pre>{<br>  &quot;name&quot;: &quot;Example&quot;,<br>  &quot;version&quot;: &quot;0.0.1&quot;,<br>  &quot;l10n&quot;: &quot;./l10n&quot;,<br>  // ...<br>}</pre><p>Then, you can use this in your extension.js</p><pre>import * as vscode from &#39;vscode&#39;;<br><br>const title = vscode.l10n.t(&#39;Example&#39;);</pre><h4>For web-view content</h4><p>What you need to do is inject the language bundle into the HTML and add @vscode/l10n as a dependency.</p><pre>class WebViewProvider {<br>  getSidebarContent() {<br>     return `<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;script&gt;<br>      window.l10nBundle = ${JSON.stringify(vscode.l10n.bundle || {})}<br>    &lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;script type=&quot;module&quot;&gt;<br>      import * as l10n from &#39;@vscode/l10n&#39;;<br>      l10n.config({<br>        contents: window.l10nBundle<br>      });<br>      const title = l10n.t(&#39;Hello&#39;);<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;<br>`<br>  }<br>}</pre><h4>Reference:</h4><p><a href="https://code.visualstudio.com/api/references/vscode-api#l10n">https://code.visualstudio.com/api/references/vscode-api#l10n</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69cd16bbf115" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Docker offline]]></title>
            <link>https://medium.com/@wangzuomeng/how-to-use-docker-offline-24460837405b?source=rss-71b793ad3911------2</link>
            <guid isPermaLink="false">https://medium.com/p/24460837405b</guid>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[offline]]></category>
            <dc:creator><![CDATA[Wang/Zuomeng]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 03:58:01 GMT</pubDate>
            <atom:updated>2024-11-25T03:58:01.040Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ul5uFYEaRhTohV3_km8c3Q.jpeg" /><figcaption>Pexels Christina Morillo: <a href="https://www.pexels.com/zh-cn/photo/1181675/">https://www.pexels.com/zh-cn/photo/1181675/</a></figcaption></figure><p>In some cases, our server is behind a firewall and isn’t allowed to connect to the internet, but we need to run docker in the server. If you want to run Docker on this machine, you can follow the steps:</p><p>First, run the following command to export the docker image you need. Don’t forget to replace the name and tag. See more: <a href="https://docs.docker.com/reference/cli/docker/image/save/">https://docs.docker.com/reference/cli/docker/image/save/</a></p><pre>docker save -o &lt;local-image-name&gt;.tar &lt;dockerhub-image-name&gt;:&lt;tag&gt;<br><br># Example<br>docker save -o nginx-1.27.2.tar nginx:1.27.2</pre><p>Second, upload the tar from the first step to your server.</p><p>Then, load the image by command. See more: <a href="https://docs.docker.com/reference/cli/docker/image/load/">https://docs.docker.com/reference/cli/docker/image/load/</a></p><pre>docker load -i &lt;local-image-name&gt;.tar<br><br># Example<br>docker load -i nginx-1.27.2.tar</pre><p>Finally, run the image</p><pre>docker run -d &lt;local-image-name&gt;.tar</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24460837405b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT 创建无历史的新分支]]></title>
            <link>https://medium.com/@wangzuomeng/git-%E5%88%9B%E5%BB%BA%E6%97%A0%E5%8E%86%E5%8F%B2%E7%9A%84%E6%96%B0%E5%88%86%E6%94%AF-e894a17a2c95?source=rss-71b793ad3911------2</link>
            <guid isPermaLink="false">https://medium.com/p/e894a17a2c95</guid>
            <category><![CDATA[git-remote]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[git-orphan]]></category>
            <dc:creator><![CDATA[Wang/Zuomeng]]></dc:creator>
            <pubDate>Wed, 13 Nov 2024 03:52:38 GMT</pubDate>
            <atom:updated>2024-11-13T03:52:38.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*YcnUqTU6n3Pn_2j3yczIdw.png" /></figure><p>有些时候仓库想要重置，或者提交到其他平台，但是不想带之前的历史提交记录，那么可以考虑一下步骤</p><p>先通过 git clone 下载代码到本地，再新建一个 orphan 分支，再重新 commit</p><pre>git clone https://git...<br><br># 新建 orphan 分支<br>git checkout --orphan 分支名称<br><br>git add .<br>git commit -m &quot;Initial commmit&quot;</pre><p>推送到远程时，如果是不同仓库，可以考虑添加新的 remote 地址</p><pre>git remote add remoteName https://git...<br><br>git push remoteName 本地分支名称:远程分支名称</pre><p>如果是相同仓库，可以考虑使用 git push -f</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e894a17a2c95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在浏览器中通过 js 解压 zip]]></title>
            <link>https://medium.com/@wangzuomeng/%E5%9C%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E4%B8%AD%E9%80%9A%E8%BF%87-js-%E8%A7%A3%E5%8E%8B-zip-b41995f27952?source=rss-71b793ad3911------2</link>
            <guid isPermaLink="false">https://medium.com/p/b41995f27952</guid>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[winzip]]></category>
            <category><![CDATA[zip]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Wang/Zuomeng]]></dc:creator>
            <pubDate>Wed, 06 Nov 2024 15:29:03 GMT</pubDate>
            <atom:updated>2024-11-06T15:29:03.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCIAYrtA2Y86ZIXY82_YHg.png" /></figure><p>最近有个需求要在浏览器端解压 zip 文件，校验文件格式，找了很久，终于找到了这个可以在浏览器端运行的 zip 解压库 @zip.js/zip.js 。</p><p>npmjs：<a href="https://www.npmjs.com/package/@zip.js/zip.js">https://www.npmjs.com/package/@zip.js/zip.js</a></p><p>主页：<a href="https://gildas-lormeau.github.io/zip.js/">https://gildas-lormeau.github.io/zip.js/</a></p><p>API 文档：<a href="https://gildas-lormeau.github.io/zip.js/api/index.html">https://gildas-lormeau.github.io/zip.js/api/index.html</a></p><h3>基础解压用法</h3><p>下面我们从最基础的用法开始，首先创建文件 index.html，复制下面代码到创建的文件中，并保存。</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;@zip.js/zip.js test&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;input id=&quot;input&quot; type=&quot;file&quot; accept=&quot;.zip&quot; /&gt;<br>    &lt;script type=&quot;module&quot;&gt;<br>      import { BlobReader, ZipReader } from &#39;https://deno.land/x/zipjs/index.js&#39;;<br>      document.querySelector(&#39;#input&#39;).addEventListener(&#39;change&#39;, async (event) =&gt; {<br>          const file = event.target.files[0];<br>          if (!file) {<br>            return;<br>          }<br>          const blobReader = new BlobReader(file);<br>          const zipReader = new ZipReader(blobReader);<br>          // 注意设置 filenameEncoding 为 utf8，否则大概率会乱码<br>          const entries = await zipReader.getEntries({ filenameEncoding: &#39;utf-8&#39; });<br>          console.log(&#39;entries&#39;, entries);<br>      })<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><blockquote>注意设置 filenameEncoding 为 utf8，否则大概率会乱码。具体可以参考<a href="https://stackoverflow.com/questions/13261347/correctly-decoding-zip-entry-file-names-cp437-utf-8-or">https://stackoverflow.com/questions/13261347/correctly-decoding-zip-entry-file-names-cp437-utf-8-or</a></blockquote><p>用浏览器（建议 chrome）打开上面创建的文件，打开开发者工具，选择一个 zip 文件，就可以在控制台中看见 zip 包中包含的所有文件内容了，参考下图。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSgprNt_RLlzpe8S_vSpZA.png" /></figure><p>可以通过 entry.directory 属性可以判断是否是文件夹。</p><p>如果要进一步读取文件内容，可以使用 TextWriter （假设压缩包内都是文本文件），代码如下：</p><pre>// 上面拿到了 entries <br>// import { TextWriter } from &#39;https://deno.land/x/zipjs/index.js&#39;;<br>entries.forEach(async (entry) =&gt; {<br>  // 如果是文件夹就跳过<br>  if (entry.directory) {<br>    return<br>  }<br>  const writer = new TextWriter();<br>  const data = await entry.getData(writer);<br>  console.log(entry.filename, data);<br>})</pre><p>将上面代码补充到刚才的文件中，不出意外就可以在浏览器中看见文件内容了。</p><p>如果要查看非文本文件，可以使用 BlobWriter ，用法类似。</p><h3>基础压缩用法</h3><p>基本上将解压中的 Reader 替换为 Writer 就可以了，比如上面解压是 ZipReader ，压缩是 ZipWriter 。</p><pre>import { BlobWriter, ZipWriter, TextReader } from &#39;https://deno.land/x/zipjs/index.js&#39;;<br><br>const zipFileWriter = new BlobWriter();<br>const zipWriter = new ZipWriter(zipFileWriter);<br><br>const helloWorldReader = new TextReader(&quot;Hello world!&quot;);<br>await zipWriter.add(&quot;floder&quot;, new TextReader(&quot;&quot;), { directory: true });<br>await zipWriter.add(&quot;floder/hello.txt&quot;, helloWorldReader);<br>await zipWriter.close();<br><br>const zipFileBlob = await zipFileWriter.getData();</pre><h3>高级能力</h3><p>为什么说这个库是神仙库呢？</p><p>首先，它支持多种环境：浏览器 / worker / nodejs / deno 等。</p><p>其次，它支持的能力很丰富，除了基础压缩和解压，还支持 WinZIP AES 和PKWare ZipCrypto 加密。</p><p>最后，它支持自定义输入输出，除了最基本的文本和 Blob，你还可以通过继承 Reader 或 Writer 来实现自己的输入输出。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b41995f27952" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>