### Installing VoerkaI18n CLI Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Provides commands to install the VoerkaI18n command-line interface globally using npm, yarn, or pnpm. This tool is essential for project initialization and content extraction. ```shell > npm install -g @voerkai18n/cli > yarn global add @voerkai18n/cli > pnpm add -g @voerkai18n/cli ``` -------------------------------- ### Develop SolidStart Project with npm run dev Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/solid/README.md Commands to start the development server for a SolidStart project. After installing dependencies, these commands launch the server, with an option to open the application in a browser. Requires Node.js and npm. ```bash npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### Start Next.js Development Server Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/nextjs/README.md Commands to initiate the development server for the Next.js project using different package managers. This allows for local development and testing of the application. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Loading Language Packs from Server Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Provides an example of a language pack loader function that fetches JSON language files from a server. This function is crucial for enabling dynamic language pack patches and adding support for new languages without modifying the application code. ```javascript module.exports = async (language,scope)=>{ return await (await fetch(`/languages/${scope.id}/${language}.json`)).json() } ``` -------------------------------- ### Initializing VoerkaI18n Project Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Illustrates the command to initialize a new multilingual environment for a project using the `voerkai18n init` command. This command sets up the necessary directory structure and configuration files. ```shell > voerkai18n init ``` -------------------------------- ### Create SolidStart Project using npm init Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/solid/README.md Commands to create a new SolidStart project. This initializes a project in the current directory or a specified directory name. It requires npm to be installed. ```bash # create a new project in the current directory npm init solid@latest # create a new project in my-app npm init solid@latest my-app ``` -------------------------------- ### Install VoerkaI18n CLI Tool Globally Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/install.md Installs the VoerkaI18n command-line interface globally using various package managers. This CLI tool is essential for text extraction and compilation. ```bash npm install -g @voerkai18n/cli ``` ```bash yarn global add @voerkai18n/cli ``` ```bash pnpm add -g @voerkai18n/cli ``` -------------------------------- ### Astro Project Commands with pnpm Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/README.md This table lists essential commands for managing an Astro project using pnpm. It covers dependency installation, starting the development server, building for production, previewing the build, and running Astro CLI commands. ```text | Command | Action | | :------------------------ | :----------------------------------------------- | | `pnpm install` | Installs dependencies | | `pnpm dev` | Starts local dev server at `localhost:4321` | | `pnpm build` | Build your production site to `./dist/` | | `pnpm preview` | Preview your build locally, before deploying | | `pnpm astro ...` | Run CLI commands like `astro add`, `astro check` | | `pnpm astro -- --help` | Get help using the Astro CLI | ``` -------------------------------- ### Install VoerkaI18n CLI Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/index.md Installs the VoerkaI18n command-line interface globally using npm, yarn, or pnpm. This CLI tool is essential for managing internationalization tasks within your project. ```shell npm install @voerkai18n/cli -g yarn global add @voerkai18n/cli pnpm add -g @voerkai18n/cli ``` -------------------------------- ### Install unplugin-starter Package Source: https://github.com/zhangfisher/voerka-i18n/blob/master/packages/plugins/README.md Installs the 'unplugin-starter' package as a project dependency. This is the first step before integrating it with build tools. ```bash npm i unplugin-starter ``` -------------------------------- ### Markdown Image Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Demonstrates the correct Markdown syntax for including images. It shows how to specify the alt text and the relative or absolute path to the image file. This is crucial for web accessibility and SEO. ```markdown ![Alt text](./full/or/relative/path/of/image) ``` -------------------------------- ### Installation Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/zh/guide/tools/cli.md Instructions on how to globally install the @voerkai18n/cli package using npm, yarn, or pnpm. ```APIDOC ## Installation Globally install the `@voerkai18n/cli` tool. ```bash > npm install -g @voerkai18n/cli ``` ```bash > yarn global add @voerkai18n/cli ``` ```bash > pnpm add -g @voerkai18n/cli ``` ``` -------------------------------- ### Markdown Ordered List Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Provides the syntax for creating ordered lists in Markdown. Each list item is preceded by a number followed by a period. This is used for sequential or numbered items. ```markdown 1. First item 2. Second item 3. Third item ``` -------------------------------- ### Install @voerkai18n/runtime and @voerkai18n/lit Source: https://github.com/zhangfisher/voerka-i18n/blob/master/packages/lit/README.md Installs the necessary runtime and Lit integration packages for VoerkaI18n using npm. Also installs the global CLI tool. ```bash npm install @voerkai18n/runtime @voerkai18n/lit npm install -g @voerkai18n/cli ``` -------------------------------- ### Automatic Translation Commands Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md These commands initiate automatic translation using VoerkaI18n. They support different translation providers like Baidu Translation and AI translation services compatible with OpenAI API. You need to provide relevant API keys and URLs. ```bash >voerkai18n translate --api-key --api-id --provider baidu ``` ```bash >voerkai18n translate --api-key --api-url --api-model ``` -------------------------------- ### Switching Languages with VoerkaI18n Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Demonstrates how to change the application's current language using the `change` method. This can be done via the `i18nScope` or the global `VoerkaI18n` singleton. The operation is asynchronous and requires awaiting its completion. ```javascript import { i18nScope } from "./languages" // Switch to English await i18nScope.change("en") // Or VoerkaI18n is a global singleton, can be accessed directly await VoerkaI18n.change("en") ``` -------------------------------- ### Markdown Table Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Shows the Markdown syntax for creating tables. Tables are defined using pipes '|' to separate columns and hyphens '-' to create header separators. This enables structured data presentation within Markdown documents. ```markdown | Italics | Bold | Code | | --------- | -------- | ------ | | _italics_ | **bold** | `code` | ``` -------------------------------- ### Extracting Translatable Text with VoerkaI18n CLI Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Shows the command used to automatically scan project source files and extract all text content wrapped in the `t` function. The extracted text is saved into `myapp/languages/translates/messages/default.json`. ```shell myapp>voerkai18n extract ``` -------------------------------- ### Initialize VoerkaI18n Project Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/index.md Initializes a new project for internationalization using the VoerkaI18n CLI. This command sets up the necessary configuration files and directory structure for translations. ```shell voerkai18n init ``` -------------------------------- ### Markdown Other Elements Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Demonstrates the Markdown syntax for various other HTML elements, including abbreviations (), subscripts (), superscripts (), keyboard input (), and highlights (). These elements allow for richer text formatting. ```markdown GIF is a bitmap image format. H2O Xn + Yn = Zn Press CTRL + ALT + Delete to end the session. Most salamanders are nocturnal, and hunt for insects, worms, and other small creatures. ``` -------------------------------- ### Marking Text for Translation in Javascript Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Demonstrates how to use the `t` function to wrap strings that require translation in Javascript files. It supports both simple strings and strings with interpolation variables. ```javascript // index.js console.log(t("中华人民共和国万岁")) console.log(t("中华人民共和国成立于{}",1949)) ``` ```javascript import { t } from "./languages" // Without interpolation variables t("中华人民共和国") // Position interpolation variables t("中华人民共和国{}","万岁") t("中华人民共和国成立于{}年,首都{}",[1949,"北京"]) ``` -------------------------------- ### Markdown Blockquote Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Illustrates how to create blockquotes in Markdown, both with and without attribution. This is useful for quoting external content or highlighting specific passages. The syntax uses the '>' character at the beginning of each line. ```markdown > Tiam, ad mint andaepu dandae nostion secatur sequo quae. > **Note** that you can use _Markdown syntax_ within a blockquote. ``` ```markdown > Don't communicate by sharing memory, share memory by communicating.
> — Rob Pike[^1] ``` -------------------------------- ### Configure Babel for VoerkaI18n Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/integration/babel.md Example JSON configuration for integrating the @voerkai18n/babel plugin into a Babel setup. This typically involves adding the plugin to the 'plugins' array in your Babel configuration file. ```json { "plugins": [ ["@voerkai18n/babel"] ] } ``` -------------------------------- ### Markdown Nested List Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Shows how to create nested lists in Markdown, allowing for hierarchical organization of content. Indentation is used to define sub-items within a list. ```markdown - Fruit - Apple - Orange - Banana - Dairy - Milk - Cheese ``` -------------------------------- ### VoerkaI18n Scope Configuration Example (JSON) Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/advanced/scope.md Provides an example of the `languages/settings.json` file, detailing the structure for configuring a scope, including its ID, default and active languages, and a list of supported languages with their names and titles. ```json { "id": "myapp", // Scope ID "default": "zh-CN", // Default language "active": "en-US", // Active language "languages": [ { "name": "zh-CN", "title": "Chinese" }, { "name": "en-US", "title": "English" } ] } ``` -------------------------------- ### Create Svelte Project Source: https://github.com/zhangfisher/voerka-i18n/blob/master/packages/svelte/README.md Commands to create a new Svelte library project. It can be initialized in the current directory or a specified new directory. Requires npx. ```bash npx sv create # create a new project in my-app npx sv create my-app ``` -------------------------------- ### HTML Code Block Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Demonstrates how to embed and highlight HTML code within a Markdown document. By using triple backticks and specifying 'html' after the opening backticks, the code is rendered with syntax highlighting, improving readability. ```markdown ```html Example HTML5 Document

Test

``` ``` -------------------------------- ### Subscribing to Language Change Events Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md Shows how to subscribe to language change events to re-render the interface or perform other actions when the language is updated. Event listeners can be attached using `on` method on either `i18nScope` or `VoerkaI18n`. ```javascript import { i18nScope } from "./languages" // Switch to English i18nScope.on("change",(newLanguage)=>{ // Re-render interface here ... }) // VoerkaI18n.on("change",(newLanguage)=>{ // Re-render interface here ... }) ``` -------------------------------- ### Install VoerkaI18n CLI Globally Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/zh/guide/integration/svelte.md Installs the VoerkaI18n command-line interface globally using npm, yarn, or pnpm. This is the first step in initializing the VoerkaI18n project. ```bash npm install -g @voerkai18n/cli ``` ```bash yarn global add @voerkai18n/cli ``` ```bash pnpm add -g @voerkai18n/cli ``` -------------------------------- ### Compile Language Packs Command Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md This command compiles the translated JSON language files into usable language packs for the application. It reads from the `translates/messages` directory and generates language files such as `zh.js`, `en.js`, etc., along with an `idMap.js`. ```shell myapp> voerkai18n compile ``` -------------------------------- ### JavaScript: Example Language Files (Initial) Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/advanced/idMap.md Illustrates the initial structure of language files in JavaScript, using full text strings as keys. This format is intuitive but leads to redundancy. ```javascript // en.js { "中华人民共和国":"the people's Republic of China" } // jp.js { "中华人民共和国":"中華人民共和国" } ``` -------------------------------- ### Build SolidStart Project using npm run build Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/solid/README.md Command to build a SolidStart application for deployment. This command uses presets to optimize the project for different environments. The default build generates a Node.js app. Requires Node.js and npm. ```bash npm run build ``` -------------------------------- ### Install @voerkai18n/react Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/integration/react.md Installation instructions for the @voerkai18n/react package using npm, yarn, and pnpm. ```shell npm install @voerkai18n/react yarn add @voerkai18n/react pnpm add @voerkai18n/react ``` -------------------------------- ### Markdown Unordered List Syntax Example Source: https://github.com/zhangfisher/voerka-i18n/blob/master/examples/astro/src/content/blog/markdown-style-guide.md Illustrates the syntax for creating unordered lists in Markdown. List items are typically denoted by hyphens '-', asterisks '*', or plus signs '+'. This is used for items where the order does not matter. ```markdown - List item - Another item - And another item ``` -------------------------------- ### Manual Translation JSON Structure Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/intro/get-started.md This JSON structure represents a typical entry in a language file for VoerkaI18n. It includes the original text as the key and translations for different languages as values, along with metadata like source files and an ID. ```json { "欢迎使用VoerkaI18n":{ "en":"", "de":"", "jp":"", "$files":["index.js"], "$id":1 }, "VoerkaI18n是一款非常棒的国际化解决方案":{ "en":"", "de":"", "jp":"", "$files":["index.js"], "$id":2 } } ``` -------------------------------- ### Install VoerkaI18n for SolidJS Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/integration/solid.md Install the `@voerkai18n/solid` package using npm, yarn, or pnpm. ```shell npm install @voerkai18n/solid yarn add @voerkai18n/solid pnpm add @voerkai18n/solid ``` -------------------------------- ### Formatter Configuration Example (ja-JP) Source: https://github.com/zhangfisher/voerka-i18n/blob/master/docs/en/guide/use/datetime.md Provides a snippet of the `languages/formatters.json` file, demonstrating the configuration structure for date formatting rules for the 'ja-JP' locale. It includes examples of setting a default format and a specific 'short' format. ```json { "ja-JP":{ "date":{ "format":"", "short":"