npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@react3l/i18next-extractor

v0.4.0

Published

Extractor for i18next applications

Downloads

42

Readme

i18next-extractor

i18next-extractor là một công cụ extract ngôn ngữ dành cho ứng dụng React sử dụng bộ i18next.

Các định nghĩa cơ bản

Translation Value

Một translation value là một giá trị được hiển thị trên màn hình cho người dùng đọc được. Ví dụ: chữ hiển thị trong nút "Đăng nhập", chữ hiển thị trong ô "Tìm kiếm", ...

Translation Key

Translation key gồm 2 phần:

  • namespace: namespace được sử dụng để gom nhóm các key thuộc cùng một domain của ứng dụng. Tất cả các translation key thuộc một namespace sẽ được gom nhóm lại thành một file json. Một namespace có thể chứa các namespace con và namespace gốc sẽ được dùng để đặt tên cho file đó.
  • key: key là giá trị duy nhất được đại diện cho một translation value thuộc nhiều ngôn ngữ khác nhau. Mỗi key sẽ phải nằm trong một namespace nào đó.

Cách đặt translation key

  • Tại mỗi vị trí cần hiển thị văn bản theo ngôn ngữ tương ứng cho người dùng đọc được, lấy domain của ứng dụng làm namespace, xem xét xem có cần thiết tạo thêm namespace con hay không, rồi dùng một từ khóa duy nhất để làm translation key

  • Đánh dấu translation key này bằng cú pháp sau:

import {translate} from 'react3l-core/helpers/internationalization';

// ...

translate('namespace.subNamespace.translationKey');

// ...
  • Có thể truyền params vào để sử dụng:
translate('namespace.subNamespace.translationKey', {param1: value1, param2: value2});
translate('namespace.subNamespace.translationKey', params);

Lưu ý:

  • do những hạn chế của biểu thức đánh dấu key, phần tham số thứ hai không nên chứa các ký tự ), (, '.
  • nếu trong thư mục mã nguồn đã xuất hiện cụm 'abc.def' là namespace, thì nó không được phép xuất hiện dưới dạng key. Ví dụ: nếu có translate('product.detail.name') rồi thì không được phép có translate('product.detail')

Command line interface

Usage: react-i18next-extract [options] [command]

Translate your application using i18next

  react-i18next-extract merge [...options]

  react-i18next-extract extract [...options]


Options:
  -V, --version                        output the version number
  -i, --input <inputPath>              Input path (default: "./src/")
  -o, --output <outputPath>            Output path (default: "./public/assets/i18n/")
  -p, --partials <partialPath>         Partial path (default: "./public/assets/i18n/partials/")
  -ic, --include <include>             Include pattern (default: "\\.(js|jsx|ts|tsx)$")
  -ex, --exclude <exclude>             Exclude pattern (default: "\\.(spec|test)\\.(js|jsx|ts|tsx)$")
  -ks, --key-separator <keySeparator>  Key separator (default: ".")
  -is, --indent-size <indent>          Indent size (default: 2)
  -l, --languages <languages...>       Supported languages (default: ["en","vi"])
  -m, --marker <marker>                Translate marker (default: "translate")
  -h, --help                           output usage information

Commands:
  extract [options]                    Extract all translations from your source code
  merge [options]                      Merge all translations for each language into a single JSON file