@embeddables/cli 0.7.18 → 0.7.19
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/.prompts/embeddables-cli.md +135 -1
- package/package.json +1 -1
|
@@ -360,7 +360,7 @@ Note: button icons and checkboxes are before text in the button, unless you set
|
|
|
360
360
|
| `ButtonText` | `<div>` | `text` set | |
|
|
361
361
|
| `ButtonDescription` | `<div>` | `description` set | |
|
|
362
362
|
| `ButtonIcon` | `<svg>`/`<span>` | `icon` or `emojiIcon` set | If `icon`, must be font-awesome icon name; if `emojiIcon` must be an emoji in text format like 😀 |
|
|
363
|
-
| `ButtonIconImage` | `<span>` | `imageUrl` set | Use **`imageUrl`** only (not `imgSrc`). SVG URLs are valid.
|
|
363
|
+
| `ButtonIconImage` | `<span>` | `imageUrl` set | Use **`imageUrl`** only (not `imgSrc`). SVG URLs are valid. |
|
|
364
364
|
|
|
365
365
|
### InputBox
|
|
366
366
|
|
|
@@ -692,6 +692,140 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
692
692
|
1. Update React file: `global-components/{locationKey}.location.tsx`
|
|
693
693
|
2. Update styles if needed
|
|
694
694
|
|
|
695
|
+
## Multi-Lingual / Translations
|
|
696
|
+
|
|
697
|
+
Embeddables support translating component text into multiple languages. The default language is English (`en`), which uses the standard component properties (e.g. `text`, `label`, `placeholder`). Translations for other languages are stored alongside these properties.
|
|
698
|
+
|
|
699
|
+
### How Translations are Stored
|
|
700
|
+
|
|
701
|
+
**In JSON** (the underlying format): Translations use flat properties with the pattern `lang--{languageCode}--{attributeKey}`. For example, a Spanish translation of a button's text would be `"lang--es--text": "Enviar"`. The default language (`en`) value is always the base property itself (e.g. `"text": "Submit"`).
|
|
702
|
+
|
|
703
|
+
**In React/TSX** (the local file format): Translations are represented as a `languages` prop — a nested object grouping translations by language code, then by attribute key. The CLI automatically converts between the two formats during compile and reverse-compile.
|
|
704
|
+
|
|
705
|
+
### Adding Translations to Components
|
|
706
|
+
|
|
707
|
+
Add a `languages` prop to any component in your `.page.tsx` or `.location.tsx` files. The prop is an object where each key is a language code (e.g. `es`, `fr`, `de`, `ja`) and each value is an object mapping attribute keys to translated strings.
|
|
708
|
+
|
|
709
|
+
**Example — PlainText with translations:**
|
|
710
|
+
|
|
711
|
+
```tsx
|
|
712
|
+
<PlainText
|
|
713
|
+
id="comp_0000000001"
|
|
714
|
+
key="welcome_heading"
|
|
715
|
+
text="Welcome to our platform"
|
|
716
|
+
languages={{
|
|
717
|
+
es: { text: 'Bienvenido a nuestra plataforma' },
|
|
718
|
+
fr: { text: 'Bienvenue sur notre plateforme' },
|
|
719
|
+
}}
|
|
720
|
+
/>
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
**Example — CustomButton with multiple translated attributes:**
|
|
724
|
+
|
|
725
|
+
```tsx
|
|
726
|
+
<CustomButton
|
|
727
|
+
id="comp_0000000002"
|
|
728
|
+
key="next_button"
|
|
729
|
+
text="Next Page >"
|
|
730
|
+
description="Head to the next step"
|
|
731
|
+
languages={{
|
|
732
|
+
es: {
|
|
733
|
+
text: 'Página siguiente >',
|
|
734
|
+
description: 'Pasar al siguiente paso',
|
|
735
|
+
},
|
|
736
|
+
fr: {
|
|
737
|
+
text: 'Page suivante >',
|
|
738
|
+
description: "Passez à l'étape suivante",
|
|
739
|
+
},
|
|
740
|
+
}}
|
|
741
|
+
/>
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
**Example — InputBox with translated label, placeholder, and validation message:**
|
|
745
|
+
|
|
746
|
+
```tsx
|
|
747
|
+
<InputBox
|
|
748
|
+
id="comp_0000000003"
|
|
749
|
+
key="email"
|
|
750
|
+
input_type="email"
|
|
751
|
+
label="Email Address"
|
|
752
|
+
placeholder="Enter your email"
|
|
753
|
+
empty_invalid_message="Email is required"
|
|
754
|
+
languages={{
|
|
755
|
+
es: {
|
|
756
|
+
label: 'Correo electrónico',
|
|
757
|
+
placeholder: 'Ingrese su correo',
|
|
758
|
+
empty_invalid_message: 'El correo es requerido',
|
|
759
|
+
},
|
|
760
|
+
fr: {
|
|
761
|
+
label: 'Adresse e-mail',
|
|
762
|
+
placeholder: 'Entrez votre e-mail',
|
|
763
|
+
empty_invalid_message: "L'e-mail est requis",
|
|
764
|
+
},
|
|
765
|
+
}}
|
|
766
|
+
/>
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
### Adding Translations to OptionSelector Buttons
|
|
770
|
+
|
|
771
|
+
For OptionSelector components, translations are added on each **button** object (not on the component itself). Add a `languages` property inside each button definition:
|
|
772
|
+
|
|
773
|
+
```tsx
|
|
774
|
+
import { OptionSelector } from '@embeddables/cli/components'
|
|
775
|
+
import type { OptionSelectorButton } from '@embeddables/cli/types'
|
|
776
|
+
|
|
777
|
+
const planButtons: OptionSelectorButton[] = [
|
|
778
|
+
{
|
|
779
|
+
id: 'button_plan_basic',
|
|
780
|
+
key: 'basic',
|
|
781
|
+
text: 'Basic Plan',
|
|
782
|
+
languages: {
|
|
783
|
+
es: { text: 'Plan Básico' },
|
|
784
|
+
fr: { text: 'Plan de base' },
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
id: 'button_plan_pro',
|
|
789
|
+
key: 'pro',
|
|
790
|
+
text: 'Pro Plan',
|
|
791
|
+
languages: {
|
|
792
|
+
es: { text: 'Plan Profesional' },
|
|
793
|
+
fr: { text: 'Plan Professionnel' },
|
|
794
|
+
},
|
|
795
|
+
},
|
|
796
|
+
]
|
|
797
|
+
|
|
798
|
+
export default function PlanPage() {
|
|
799
|
+
return <OptionSelector id="comp_0000000004" key="plan_selector" buttons={planButtons} />
|
|
800
|
+
}
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
### Translatable Attributes
|
|
804
|
+
|
|
805
|
+
Any text-based attribute on a component can be translated. Common translatable attributes include:
|
|
806
|
+
|
|
807
|
+
| Component Type | Translatable Attributes |
|
|
808
|
+
| ------------------ | ------------------------------------------------------------------ |
|
|
809
|
+
| `PlainText` | `text` |
|
|
810
|
+
| `RichTextMarkdown` | `text` |
|
|
811
|
+
| `CustomButton` | `text`, `description` |
|
|
812
|
+
| `InputBox` | `label`, `placeholder`, `empty_invalid_message` |
|
|
813
|
+
| `OptionSelector` | `label` (on the component); `text`, `description` (on each button) |
|
|
814
|
+
| `MediaImage` | `caption`, `alt_text` |
|
|
815
|
+
| `FileUpload` | `label` |
|
|
816
|
+
|
|
817
|
+
### Language Codes
|
|
818
|
+
|
|
819
|
+
Use standard ISO 639-1 two-letter language codes: `es` (Spanish), `fr` (French), `de` (German), `pt` (Portuguese), `ja` (Japanese), `zh` (Chinese), `ko` (Korean), `ar` (Arabic), `it` (Italian), `nl` (Dutch), etc.
|
|
820
|
+
|
|
821
|
+
### Key Rules
|
|
822
|
+
|
|
823
|
+
1. **Default language is always `en`** — English text goes in the base property (e.g. `text="Submit"`), never in the `languages` prop.
|
|
824
|
+
2. **Only translate non-default languages** — The `languages` prop should only contain entries for non-English languages.
|
|
825
|
+
3. **Attribute keys must match** — The keys inside each language object (e.g. `text`, `label`) must match the actual component prop names exactly.
|
|
826
|
+
4. **The `languages` prop is optional** — Components without translations simply omit it.
|
|
827
|
+
5. **Translations round-trip cleanly** — The CLI converts `languages` → flat `lang--` properties when compiling to JSON, and flat `lang--` properties → `languages` when reverse-compiling to React. No manual conversion is needed.
|
|
828
|
+
|
|
695
829
|
## Important Notes
|
|
696
830
|
|
|
697
831
|
- **IDs**: All components, pages, computed fields, actions, conditions, and buttons inside OptionSelectors have unique `id` properties. These are preserved in config.json and used for internal references, except for component and button ids which should always be written in React. **ID format**: Use a prefix plus 10 digits so generated IDs don't collide with real ones: pages → `page_` + 10 digits (e.g. `page_1234567890`); components → `comp_` + 10 digits; conditions → `cond_` + 10 digits (e.g. `cond_1234567890`); option buttons → `button_` prefix (e.g. `button_plan_basic`). Must be unique across the flow.
|