@lingui/swc-plugin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@lingui/swc-plugin",
3
+ "version": "0.1.0",
4
+ "description": "A SWC Plugin for LinguiJS",
5
+ "author": {
6
+ "name": "Timofei Iatsenko",
7
+ "email": "ty@road.travel"
8
+ },
9
+ "license": "ISC",
10
+ "keywords": [
11
+ "swc-plugin",
12
+ "swc",
13
+ "nextjs",
14
+ "lingui",
15
+ "lingui-js",
16
+ "icu",
17
+ "message-format",
18
+ "i18n",
19
+ "internalization"
20
+ ],
21
+ "main": "target/wasm32-wasi/release/lingui_macro_plugin.wasm",
22
+ "exports": {
23
+ ".": "./target/wasm32-wasi/release/lingui_macro_plugin.wasm"
24
+ },
25
+ "scripts": {
26
+ "prepublishOnly": "cargo build-wasi --release"
27
+ },
28
+ "files": [],
29
+ "packageManager": "yarn@3.3.1"
30
+ }
package/readme.md ADDED
@@ -0,0 +1,68 @@
1
+ # A SWC Plugin For LinguiJS
2
+
3
+ ## Description
4
+ This is a Rust versions of [LinguiJS Macro](https://lingui.js.org/ref/macro.html)
5
+
6
+ # Usage
7
+
8
+ `.swcrc`
9
+ https://swc.rs/docs/configuration/swcrc
10
+
11
+ ```json5
12
+ {
13
+ "$schema": "https://json.schemastore.org/swcrc",
14
+ "jsc": {
15
+ "experimental": {
16
+ "plugins": ["@lingui/swc-plugin", {
17
+
18
+ // Optional
19
+ // Unlike the JS version this option must be passed as object only.
20
+ // Docs https://lingui.js.org/ref/conf.html#std-config-runtimeConfigModule
21
+ "runtimeModules": {
22
+ "i18n": ["@lingui/core", "i18n"],
23
+ "trans": ["@lingui/react", "Trans"]
24
+ }
25
+ }]
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### Tasks:
32
+ - [x] Essential `t` macro cases:
33
+ - [x] ``t`Some string` ``
34
+ - [x] ``t`Some ${variable} string` ``
35
+ - [x] ``t`Some ${expression} string` ``
36
+ - [x] ``t(i18n)`Some string` `` - custom i18n instance
37
+ - [x] dedup values object literal when the same variable appears few time, eq avoid `{name, name, count}`
38
+ - [x] NON Essential `t` macro cases:
39
+ - [x] `t({ message descriptor })` call with message descriptor object
40
+ - [x] Passing other macros as arguments for `t()` eq: `t({message: plural(...)})`
41
+ - [x] `defineMessage`
42
+ - [x] Transform
43
+ - [x] Strip non-essential props on production
44
+ - [x] JS ICU calls (plural, select, selectOrdinal)
45
+ - [x] ``plural(count, {one: '# item', few: '# items'})`` - simple strings
46
+ - [x] ``plural(count, {one: `${variable} # item`, few: '# items'})`` - tpls with placeholders
47
+ - [x] ``plural(expression(), {one: `${variable} # item`, few: '# items'})`` - expression as parameter
48
+ - [x] dedup values object literal when the same variable appears few time, eq avoid `{name, name, count}`
49
+ - [x] nesting expressions as described here https://lingui.js.org/ref/macro.html#plural
50
+ - [X] Support `offset:1` and exact matches `=1 {...}`
51
+ - [x] Support JSX transformation
52
+ - [x] `<Trans>`
53
+ - [x] Simple cases `<Trans>Hello World</Trans>` -> `<Trans message="Hello World" />`
54
+ - [x] Variables interpolation `<Trans>Hello {name} and {getName()}</Trans>` -> `<Trans variables={name, 1: getName()} msg="Hello {name} and {1}"/>`
55
+ - [x] Recursive Components interpolation `<Trans>Hello <strong>World!</strong></Trans>`
56
+ - [x] Support edge cases `<Trans>{'Hello World'}</Trans>` and ``<Trans>{`How much is ${expression}? ${count}`}</Trans>``
57
+ - [x] Normalizing whitespaces
58
+ - [x] Stripping non-essential props in production
59
+ - [x] ICU: `<Plural>` `<SelectOrdinal>` `<Select>`
60
+ - [x] Support `offset:1` and exact matches `=1 {...}`
61
+ - [x] Support narrowing transformation to only function exported from `@lingui/macro`
62
+ - [x] Automatic adding `import { i18n } from @lingui/core`
63
+ - [x] Unicode escaping, validate how SWC produce values
64
+ - [x] Support `runtimeConfigModule` settings
65
+ - [ ] NON-ESSENTIAL Injecting uniq variables, avoiding collision with existing variables
66
+ - [ ] NON-ESSENTIAL support renamed macro calls `import {t as macroT} from "@lingui/macro"`
67
+ - [ ] Error handling: how to properly behave to do if user passed something not expected [HANDLER](https://rustdoc.swc.rs/swc_common/errors/struct.Handler.html)
68
+ - [ ] Building binary and publishing